1 /*
2 * FFV1 encoder 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
24
27 int plane_index,
int bits)
28 {
31 int x;
33 int run_count = 0;
34 int run_mode = 0;
35
37 if (
c->bytestream_end -
c->bytestream <
w * 35) {
40 }
41 } else {
45 }
46 }
47
48 if (
s->slice_coding_mode == 1) {
49 for (x = 0; x <
w; x++) {
55 }
56 }
57 return 0;
58 }
59
60 for (x = 0; x <
w; x++) {
62
65
69 }
70
72
77 } else {
79 }
80 } else {
82 run_mode = 1;
83
84 if (run_mode) {
90 }
91
95 run_count = 0;
96 run_mode = 0;
99 } else {
100 run_count++;
101 }
102 }
103
104 ff_dlog(
s->avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
107
108 if (run_mode == 0)
110 }
111 }
112 if (run_mode) {
117 }
118
119 if (run_count)
121 }
123
124 return 0;
125 }
126
129 {
131 const int ring_size =
s->context_model ? 3 : 2;
133 int lbd =
s->bits_per_raw_sample <= 8;
134 int packed = !
src[1];
135 int bits =
s->bits_per_raw_sample > 0 ?
s->bits_per_raw_sample : 8;
139
141
143 (
w + 6) *
sizeof(*
RENAME(
s->sample_buffer)));
144
145 for (y = 0; y <
h; y++) {
149
150 for (x = 0; x <
w; x++) {
152 if (lbd) {
153 unsigned v = *((
const uint32_t*)(
src[0] + x*4 +
stride[0]*y));
156 r = (v >> 16) & 0xFF;
158 } else if (packed) {
159 const uint16_t *p = ((
const uint16_t*)(
src[0] + x*packed_size +
stride[0]*y));
166 g = *((
const uint16_t *)(
src[0] + x*2 +
stride[0]*y));
167 b = *((
const uint16_t *)(
src[1] + x*2 +
stride[1]*y));
168 r = *((
const uint16_t *)(
src[2] + x*2 +
stride[2]*y));
170 a = *((
const uint16_t *)(
src[3] + x*2 +
stride[3]*y));
171 } else {
172 b = *((
const uint16_t *)(
src[0] + x*2 +
stride[0]*y));
173 g = *((
const uint16_t *)(
src[1] + x*2 +
stride[1]*y));
174 r = *((
const uint16_t *)(
src[2] + x*2 +
stride[2]*y));
175 }
176
177 if (
s->slice_coding_mode != 1) {
180 g += (
b *
s->slice_rct_by_coef +
r *
s->slice_rct_ry_coef) >> 2;
183 }
184
189 }
194 if (lbd &&
s->slice_coding_mode == 0)
196 else
200 }
201 }
202 return 0;
203 }
204