1 /*
2 * FFV1 decoder template
3 *
4 * Copyright (c) 2003-2016 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
25 int plane_index,
int bits)
26 {
29 int x;
30 int run_count = 0;
31 int run_mode = 0;
33
36
37 if (
s->slice_coding_mode == 1) {
39 for (x = 0; x <
w; x++) {
40 int v = 0;
44 }
46 }
47 return 0;
48 }
49
50 for (x = 0; x <
w; x++) {
52
53 if (!(x & 1023)) {
56 }
57
61 sign = 1;
62 } else
63 sign = 0;
64
66
69 } else {
70 if (
context == 0 && run_mode == 0)
71 run_mode = 1;
72
73 if (run_mode) {
74 if (run_count == 0 && run_mode == 1) {
77 if (x + run_count <=
w)
79 } else {
82 else
83 run_count = 0;
86 run_mode = 2;
87 }
88 }
90 while (run_count > 1 &&
w-x > 1) {
92 x++;
93 run_count--;
94 }
95 } else {
96 while (run_count > 1 &&
w-x > 1) {
98 x++;
99 run_count--;
100 }
101 }
102 run_count--;
103 if (run_count < 0) {
104 run_mode = 0;
105 run_count = 0;
110 } else
112 } else
114
115 ff_dlog(
s->avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
117 }
118
119 if (sign)
121
123 }
125 return 0;
126 }
127
129 {
130 int x, y, p;
132 int lbd =
s->avctx->bits_per_raw_sample <= 8;
133 int bits =
s->avctx->bits_per_raw_sample > 0 ?
s->avctx->bits_per_raw_sample : 8;
136
137 for (x = 0; x < 4; x++) {
139 sample[x][1] =
RENAME(
s->sample_buffer) + (x * 2 + 1) * (
w + 6) + 3;
140 }
141
143
144 memset(
RENAME(
s->sample_buffer), 0, 8 * (
w + 6) *
sizeof(*
RENAME(
s->sample_buffer)));
145
146 for (y = 0; y <
h; y++) {
150
153
156 if (lbd &&
s->slice_coding_mode == 0)
158 else
162 }
163 for (x = 0; x <
w; x++) {
168
169 if (
s->slice_coding_mode != 1) {
172 g -= (
b *
s->slice_rct_by_coef +
r *
s->slice_rct_ry_coef) >> 2;
175 }
176
177 if (lbd)
178 *((uint32_t*)(
src[0] + x*4 +
stride[0]*y)) =
b + ((
unsigned)
g<<8) + ((
unsigned)
r<<16) + ((
unsigned)
a<<24);
180 *((uint16_t*)(
src[0] + x*2 +
stride[0]*y)) =
g;
181 *((uint16_t*)(
src[1] + x*2 +
stride[1]*y)) =
b;
182 *((uint16_t*)(
src[2] + x*2 +
stride[2]*y)) =
r;
184 *((uint16_t*)(
src[3] + x*2 +
stride[3]*y)) =
a;
185 } else {
186 *((uint16_t*)(
src[0] + x*2 +
stride[0]*y)) =
b;
187 *((uint16_t*)(
src[1] + x*2 +
stride[1]*y)) =
g;
188 *((uint16_t*)(
src[2] + x*2 +
stride[2]*y)) =
r;
189 }
190 }
191 }
192 return 0;
193 }