FFmpeg
photocd.c
Go to the documentation of this file.
1 /*
2  * Kodak PhotoCD (a.k.a. ImagePac) image decoder
3  *
4  * Copyright (c) 1996-2002 Gerd Knorr
5  * Copyright (c) 2010 Kenneth Vermeirsch
6  * Copyright (c) 2020 Paul B Mahol
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 /**
26  * @file
27  * Kodak PhotoCD (a.k.a. ImagePac) image decoder
28  *
29  * Supports resolutions up to 3072x2048.
30  */
31 
32 #define CACHED_BITSTREAM_READER !ARCH_X86_32
33 
34 #include "libavutil/intreadwrite.h"
35 #include "libavutil/opt.h"
36 #include "avcodec.h"
37 #include "bytestream.h"
38 #include "codec_internal.h"
39 #include "get_bits.h"
40 #include "internal.h"
41 #include "thread.h"
42 
43 typedef struct PhotoCDContext {
44  AVClass *class;
45  int lowres;
46 
48  int thumbnails; //* number of thumbnails; 0 for normal image */
51 
52  int streampos;
53 
54  uint8_t bits[256];
55  uint16_t codes[256];
56  uint8_t syms[256];
57 
58  VLC vlc[3];
60 
61 typedef struct ImageInfo {
62  uint32_t start;
63  uint16_t width, height;
64 } ImageInfo;
65 
66 static const ImageInfo img_info[6] = {
67  {8192, 192, 128},
68  {47104, 384, 256},
69  {196608, 768, 512},
70  {0, 1536, 1024},
71  {0, 3072, 2048},
72  {0, 6144, 4096},
73 };
74 
76  int width, int height)
77 {
78  GetByteContext *gb = &s->gb;
79  int start = s->streampos + img_info[2].start;
80  uint8_t *ptr, *ptr1, *ptr2;
81  uint8_t *dst;
82  int fill;
83 
84  ptr = picture->data[0];
85  ptr1 = picture->data[1];
86  ptr2 = picture->data[2];
87 
88  bytestream2_seek(gb, start, SEEK_SET);
89 
90  for (int y = 0; y < height; y += 2) {
91  dst = ptr;
92  for (int x = 0; x < width - 1; x++) {
93  fill = bytestream2_get_byte(gb);
94  *(dst++) = fill;
95  *(dst++) = (fill + bytestream2_peek_byte(gb) + 1) >> 1;
96  }
97  fill = bytestream2_get_byte(gb);
98  *(dst++) = fill;
99  *(dst++) = fill;
100 
101  ptr += picture->linesize[0] << 1;
102 
103  dst = ptr;
104  for (int x = 0; x < width - 1; x++) {
105  fill = bytestream2_get_byte(gb);
106  *(dst++) = fill;
107  *(dst++) = (fill + bytestream2_peek_byte(gb) + 1) >> 1;
108  }
109  fill = bytestream2_get_byte(gb);
110  *(dst++) = fill;
111  *(dst++) = fill;
112 
113  ptr += picture->linesize[0] << 1;
114 
115  dst = ptr1;
116  for (int x = 0; x < (width >> 1) - 1; x++) {
117  fill = bytestream2_get_byte(gb);
118  *(dst++) = fill;
119  *(dst++) = (fill + bytestream2_peek_byte(gb) + 1) >> 1;
120  }
121  fill = bytestream2_get_byte(gb);
122  *(dst++) = fill;
123  *(dst++) = fill;
124 
125  ptr1 += picture->linesize[1] << 1;
126 
127  dst = ptr2;
128  for (int x = 0; x < (width >> 1) - 1; x++) {
129  fill = bytestream2_get_byte(gb);
130  *(dst++) = fill;
131  *(dst++) = (fill + bytestream2_peek_byte(gb) + 1) >> 1;
132  }
133  fill = bytestream2_get_byte(gb);
134  *(dst++) = fill;
135  *(dst++) = fill;
136 
137  ptr2 += picture->linesize[2] << 1;
138  }
139 
140  s->streampos += bytestream2_tell(gb) - start;
141 }
142 
143 static av_noinline void interp_lines(uint8_t *ptr, int linesize,
144  int width, int height)
145 {
146  const uint8_t *src1;
147  uint8_t *dst;
148  int x;
149 
150  for (int y = 0; y < height - 2; y += 2) {
151  const uint8_t *src1 = ptr;
152  uint8_t *dst = ptr + linesize;
153  const uint8_t *src2 = dst + linesize;
154  for (x = 0; x < width - 2; x += 2) {
155  dst[x] = (src1[x] + src2[x] + 1) >> 1;
156  dst[x + 1] = (src1[x] + src2[x] + src1[x + 2] + src2[x + 2] + 2) >> 2;
157  }
158  dst[x] = dst[x + 1] = (src1[x] + src2[x] + 1) >> 1;
159 
160  ptr += linesize << 1;
161  }
162 
163  src1 = ptr;
164  dst = ptr + linesize;
165  for (x = 0; x < width - 2; x += 2) {
166  dst[x] = src1[x];
167  dst[x + 1] = (src1[x] + src1[x + 2] + 1) >> 1;
168  }
169  dst[x] = dst[x + 1] = src1[x];
170 }
171 
172 static av_noinline void interp_pixels(uint8_t *ptr, int linesize,
173  int width, int height)
174 {
175  for (int y = height - 2; y >= 0; y -= 2) {
176  const uint8_t *src = ptr + (y >> 1) * linesize;
177  uint8_t *dst = ptr + y * linesize;
178 
179  dst[width - 2] = dst[width - 1] = src[(width >> 1) - 1];
180  for (int x = width - 4; x >= 0; x -= 2) {
181  dst[x] = src[x >> 1];
182  dst[x + 1] = (src[x >> 1] + src[(x >> 1) + 1] + 1) >> 1;
183  }
184  }
185 }
186 
188 {
189  PhotoCDContext *s = avctx->priv_data;
190  GetByteContext *gb = &s->gb;
191  int start = s->streampos;
192  int count, ret;
193 
194  bytestream2_seek(gb, start, SEEK_SET);
195 
196  count = bytestream2_get_byte(gb) + 1;
197  if (bytestream2_get_bytes_left(gb) < count * 4)
198  return AVERROR_INVALIDDATA;
199 
200  for (int j = 0; j < count; j++) {
201  const int bit = bytestream2_get_byteu(gb) + 1;
202  const int code = bytestream2_get_be16u(gb);
203  const int sym = bytestream2_get_byteu(gb);
204 
205  if (bit > 16)
206  return AVERROR_INVALIDDATA;
207 
208  s->bits[j] = bit;
209  s->codes[j] = code >> (16 - bit);
210  s->syms[j] = sym;
211  }
212 
213  ff_free_vlc(vlc);
214  ret = ff_init_vlc_sparse(vlc, 12, count,
215  s->bits, sizeof(*s->bits), sizeof(*s->bits),
216  s->codes, sizeof(*s->codes), sizeof(*s->codes),
217  s->syms, sizeof(*s->syms), sizeof(*s->syms), 0);
218 
219  s->streampos = bytestream2_tell(gb);
220 
221  return ret;
222 }
223 
225  int target_res, int curr_res)
226 {
227  PhotoCDContext *s = avctx->priv_data;
229  GetByteContext *gb = &s->gb;
230  int ret, y = 0, type, height;
231  int start = s->streampos;
232  unsigned shiftreg;
233  const int scaling = target_res - curr_res;
234  const uint8_t type2idx[] = { 0, 0xff, 1, 2 };
235 
236  bytestream2_seek(gb, start, SEEK_SET);
238  if (ret < 0)
239  return ret;
240 
241  height = img_info[curr_res].height;
242 
243  while (y < height) {
244  uint8_t *data;
245  int x2, idx;
246 
247  for (; get_bits_left(&g) > 0;) {
248  if (show_bits(&g, 12) == 0xfff)
249  break;
250  skip_bits(&g, 8);
251  }
252 
253  shiftreg = show_bits(&g, 24);
254  while (shiftreg != 0xfffffe) {
255  if (get_bits_left(&g) <= 0)
256  return AVERROR_INVALIDDATA;
257  skip_bits(&g, 1);
258  shiftreg = show_bits(&g, 24);
259  }
260  skip_bits(&g, 24);
261  y = show_bits(&g, 15) & 0x1fff;
262  if (y >= height)
263  break;
264  type = get_bits(&g, 2);
265  skip_bits(&g, 14);
266 
267  if (type == 1)
268  return AVERROR_INVALIDDATA;
269  idx = type2idx[type];
270 
271  data = frame->data[idx] + (y >> !!idx) * frame->linesize[idx];
272 
273  x2 = avctx->width >> (scaling + !!idx);
274  for (int x = 0; x < x2; x++) {
275  int m;
276 
277  if (get_bits_left(&g) <= 0)
278  return AVERROR_INVALIDDATA;
279  m = get_vlc2(&g, s->vlc[idx].table, s->vlc[idx].bits, 2);
280  if (m < 0)
281  return AVERROR_INVALIDDATA;
282  m = sign_extend(m, 8);
283  data[x] = av_clip_uint8(data[x] + m);
284  }
285  }
286 
287  s->streampos += (get_bits_count(&g) + 7) >> 3;
288  s->streampos = (s->streampos + 0x6000 + 2047) & ~0x7ff;
289 
290  return 0;
291 }
292 
294  int *got_frame, AVPacket *avpkt)
295 {
296  PhotoCDContext *s = avctx->priv_data;
297  const uint8_t *buf = avpkt->data;
298  GetByteContext *gb = &s->gb;
299  uint8_t *ptr, *ptr1, *ptr2;
300  int ret;
301 
302  if (avpkt->size < img_info[0].start)
303  return AVERROR_INVALIDDATA;
304 
305  if (!memcmp("PCD_OPA", buf, 7)) {
306  s->thumbnails = AV_RL16(buf + 10);
307  av_log(avctx, AV_LOG_WARNING, "this is a thumbnails file, "
308  "reading first thumbnail only\n");
309  } else if (avpkt->size < 786432) {
310  return AVERROR_INVALIDDATA;
311  } else if (memcmp("PCD_IPI", buf + 0x800, 7)) {
312  return AVERROR_INVALIDDATA;
313  }
314 
315  s->orientation = s->thumbnails ? buf[12] & 3 : buf[0x48] & 3;
316 
317  if (s->thumbnails)
318  s->resolution = 0;
319  else if (avpkt->size <= 788480)
320  s->resolution = 2;
321  else
322  s->resolution = av_clip(4 - s->lowres, 0, 4);
323 
324  ret = ff_set_dimensions(avctx, img_info[s->resolution].width, img_info[s->resolution].height);
325  if (ret < 0)
326  return ret;
327 
328  if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
329  return ret;
330 
332  p->key_frame = 1;
333 
334  bytestream2_init(gb, avpkt->data, avpkt->size);
335 
336  if (s->resolution < 3) {
337  ptr = p->data[0];
338  ptr1 = p->data[1];
339  ptr2 = p->data[2];
340 
341  if (s->thumbnails)
342  bytestream2_seek(gb, 10240, SEEK_SET);
343  else
344  bytestream2_seek(gb, img_info[s->resolution].start, SEEK_SET);
345 
346  for (int y = 0; y < avctx->height; y += 2) {
347  bytestream2_get_buffer(gb, ptr, avctx->width);
348  ptr += p->linesize[0];
349 
350  bytestream2_get_buffer(gb, ptr, avctx->width);
351  ptr += p->linesize[0];
352 
353  bytestream2_get_buffer(gb, ptr1, avctx->width >> 1);
354  ptr1 += p->linesize[1];
355 
356  bytestream2_get_buffer(gb, ptr2, avctx->width >> 1);
357  ptr2 += p->linesize[2];
358  }
359  } else {
360  s->streampos = 0;
361  ptr = p->data[0];
362  ptr1 = p->data[1];
363  ptr2 = p->data[2];
364 
366 
367  interp_lines(ptr1, p->linesize[1], img_info[2].width, img_info[2].height);
368  interp_lines(ptr2, p->linesize[2], img_info[2].width, img_info[2].height);
369 
370  if (s->resolution == 4) {
371  interp_pixels(ptr1, p->linesize[1], img_info[3].width, img_info[3].height);
372  interp_lines (ptr1, p->linesize[1], img_info[3].width, img_info[3].height);
373  interp_pixels(ptr2, p->linesize[2], img_info[3].width, img_info[3].height);
374  interp_lines (ptr2, p->linesize[2], img_info[3].width, img_info[3].height);
375  }
376 
377  interp_lines(ptr, p->linesize[0], img_info[3].width, img_info[3].height);
378 
379  s->streampos = 0xc2000;
380  for (int n = 0; n < 3; n++) {
381  if ((ret = read_hufftable(avctx, &s->vlc[n])) < 0)
382  return ret;
383  }
384  s->streampos = (s->streampos + 2047) & ~0x3ff;
385  if (decode_huff(avctx, p, s->resolution, 3) < 0)
386  return AVERROR_INVALIDDATA;
387 
388  if (s->resolution == 4) {
389  interp_pixels(ptr, p->linesize[0], img_info[4].width, img_info[4].height);
390  interp_lines (ptr, p->linesize[0], img_info[4].width, img_info[4].height);
391 
392  for (int n = 0; n < 3; n++) {
393  if ((ret = read_hufftable(avctx, &s->vlc[n])) < 0)
394  return ret;
395  }
396  s->streampos = (s->streampos + 2047) & ~0x3ff;
397  if (decode_huff(avctx, p, 4, 4) < 0)
398  return AVERROR_INVALIDDATA;
399  }
400  }
401 
402  {
403  ptr1 = p->data[1];
404  ptr2 = p->data[2];
405 
406  for (int y = 0; y < avctx->height >> 1; y++) {
407  for (int x = 0; x < avctx->width >> 1; x++) {
408  ptr1[x] = av_clip_uint8(ptr1[x] - 28);
409  ptr2[x] = av_clip_uint8(ptr2[x] - 9);
410  }
411 
412  ptr1 += p->linesize[1];
413  ptr2 += p->linesize[2];
414  }
415  }
416 
417  *got_frame = 1;
418 
419  return 0;
420 }
421 
423 {
424  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
425  avctx->colorspace = AVCOL_SPC_BT709;
428  avctx->color_range = AVCOL_RANGE_JPEG;
429 
430  return 0;
431 }
432 
434 {
435  PhotoCDContext *s = avctx->priv_data;
436 
437  for (int i = 0; i < 3; i++)
438  ff_free_vlc(&s->vlc[i]);
439 
440  return 0;
441 }
442 
443 #define OFFSET(x) offsetof(PhotoCDContext, x)
444 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
445 
446 static const AVOption options[] = {
447  { "lowres", "Lower the decoding resolution by a power of two",
448  OFFSET(lowres), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VD },
449  { NULL },
450 };
451 
452 static const AVClass photocd_class = {
453  .class_name = "photocd",
454  .item_name = av_default_item_name,
455  .option = options,
456  .version = LIBAVUTIL_VERSION_INT,
457 };
458 
460  .p.name = "photocd",
461  .p.type = AVMEDIA_TYPE_VIDEO,
462  .p.id = AV_CODEC_ID_PHOTOCD,
463  .priv_data_size = sizeof(PhotoCDContext),
464  .p.priv_class = &photocd_class,
465  .init = photocd_decode_init,
466  .close = photocd_decode_close,
468  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
469  .p.long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
470  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
471 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
av_clip
#define av_clip
Definition: common.h:95
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:839
opt.h
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:966
photocd_decode_close
static av_cold int photocd_decode_close(AVCodecContext *avctx)
Definition: photocd.c:433
PhotoCDContext::gb
GetByteContext gb
Definition: photocd.c:47
GetByteContext
Definition: bytestream.h:33
photocd_decode_frame
static int photocd_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Definition: photocd.c:293
src1
const pixel * src1
Definition: h264pred_template.c:421
VD
#define VD
Definition: photocd.c:444
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
bytestream2_seek
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
Definition: bytestream.h:212
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:959
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:599
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:374
AVOption
AVOption.
Definition: opt.h:251
data
const char data[16]
Definition: mxf.c:143
FFCodec
Definition: codec_internal.h:112
decode_huff
static av_noinline int decode_huff(AVCodecContext *avctx, AVFrame *frame, int target_res, int curr_res)
Definition: photocd.c:224
thread.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:346
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:116
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:510
GetBitContext
Definition: get_bits.h:61
ff_thread_get_buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames. The frames must then be freed with ff_thread_release_buffer(). Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
ImageInfo::start
uint32_t start
Definition: photocd.c:62
AVFrame::key_frame
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:417
av_noinline
#define av_noinline
Definition: attributes.h:72
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
interp_pixels
static av_noinline void interp_pixels(uint8_t *ptr, int linesize, int width, int height)
Definition: photocd.c:172
OFFSET
#define OFFSET(x)
Definition: photocd.c:443
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:952
interp_lines
static av_noinline void interp_lines(uint8_t *ptr, int linesize, int width, int height)
Definition: photocd.c:143
av_cold
#define av_cold
Definition: attributes.h:90
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:667
width
#define width
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:254
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
g
const char * g
Definition: vf_curves.c:117
GetByteContext::buffer
const uint8_t * buffer
Definition: bytestream.h:34
get_bits.h
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
PhotoCDContext::codes
uint16_t codes[256]
Definition: photocd.c:55
PhotoCDContext::vlc
VLC vlc[3]
Definition: photocd.c:58
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:113
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:973
read_hufftable
static av_noinline int read_hufftable(AVCodecContext *avctx, VLC *vlc)
Definition: photocd.c:187
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:473
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
interp_lowres
static av_noinline void interp_lowres(PhotoCDContext *s, AVFrame *picture, int width, int height)
Definition: photocd.c:75
bytestream2_get_buffer
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
lowres
static int lowres
Definition: ffplay.c:335
get_vlc2
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:787
img_info
static const ImageInfo img_info[6]
Definition: photocd.c:66
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
bytestream2_tell
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:192
AV_CODEC_ID_PHOTOCD
@ AV_CODEC_ID_PHOTOCD
Definition: codec_id.h:304
PhotoCDContext::lowres
int lowres
Definition: photocd.c:45
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:422
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:375
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
codec_internal.h
photocd_class
static const AVClass photocd_class
Definition: photocd.c:452
height
#define height
ImageInfo::height
uint16_t height
Definition: photocd.c:63
PhotoCDContext::resolution
int resolution
Definition: photocd.c:49
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
show_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:446
ff_init_vlc_sparse
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: vlc.c:272
PhotoCDContext::streampos
int streampos
Definition: photocd.c:52
src2
const pixel * src2
Definition: h264pred_template.c:422
PhotoCDContext
Definition: photocd.c:43
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: codec_internal.h:31
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:203
AVCodecContext::height
int height
Definition: avcodec.h:562
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:599
ff_free_vlc
void ff_free_vlc(VLC *vlc)
Definition: vlc.c:375
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
PhotoCDContext::bits
uint8_t bits[256]
Definition: photocd.c:54
options
static const AVOption options[]
Definition: photocd.c:446
AVCodecContext
main external API structure.
Definition: avcodec.h:389
PhotoCDContext::orientation
int orientation
Definition: photocd.c:50
PhotoCDContext::thumbnails
int thumbnails
Definition: photocd.c:48
VLC
Definition: vlc.h:31
photocd_decode_init
static av_cold int photocd_decode_init(AVCodecContext *avctx)
Definition: photocd.c:422
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
sign_extend
static av_const int sign_extend(int val, unsigned bits)
Definition: mathops.h:132
av_clip_uint8
#define av_clip_uint8
Definition: common.h:101
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:90
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:416
ff_photocd_decoder
const FFCodec ff_photocd_decoder
Definition: photocd.c:459
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:562
bytestream.h
PhotoCDContext::syms
uint8_t syms[256]
Definition: photocd.c:56
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:370
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:527
ImageInfo
Definition: photocd.c:61
ImageInfo::width
uint16_t width
Definition: photocd.c:63