FFmpeg: libavcodec/ffv1dec.c Source File
Go to the documentation of this file. 1 /*
2 * FFV1 decoder
3 *
4 * Copyright (c) 2003-2013 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
23 /**
24 * @file
25 * FF Video Codec 1 (a lossless codec) decoder
26 */
27
42
44 int is_signed)
45 {
47 return 0;
48 else {
51 e = 0;
53 e++;
54 if (e > 31)
56 }
57
59 for (
i = e - 1;
i >= 0;
i--)
61
64 }
65 }
66
68 {
70 }
71
74 {
76
78 k = 0;
79 while (i < state->error_sum) { // FIXME: optimize
80 k++;
82 }
83
85 ff_dlog(
NULL,
"v:%d bias:%d error:%d drift:%d count:%d k:%d",
87
88 v ^= ((2 *
state->drift +
state->count) >> 31);
89
91
93
95 }
96
98 {
103 } else {
106 }
107 return 0;
108 }
109
110 #define TYPE int16_t
111 #define RENAME(name) name
113 #undef TYPE
114 #undef RENAME
115
117 #define RENAME(name) name ## 32
119
121 int w,
int h,
int stride,
int plane_index,
122 int pixel_stride)
123 {
124 int x, y;
126 sample[0] =
s->sample_buffer + 3;
127 sample[1] =
s->sample_buffer +
w + 6 + 3;
128
130
131 memset(
s->sample_buffer, 0, 2 * (
w + 6) *
sizeof(*
s->sample_buffer));
132
133 for (y = 0; y <
h; y++) {
134 int16_t *
temp =
sample[0];
// FIXME: try a normal buffer
135
138
141
142 if (
s->avctx->bits_per_raw_sample <= 8) {
146 for (x = 0; x <
w; x++)
148 } else {
152 if (
s->packed_at_lsb) {
153 for (x = 0; x <
w; x++) {
155 }
156 } else {
157 for (x = 0; x <
w; x++) {
158 ((uint16_t*)(
src +
stride*y))[x*pixel_stride] =
sample[1][x] << (16 -
s->avctx->bits_per_raw_sample) | ((uint16_t **)
sample)[1][x] >> (2 *
s->avctx->bits_per_raw_sample - 16);
159 }
160 }
161 }
162 }
163 return 0;
164 }
165
167 {
171 int sx, sy, sw, sh;
172
178
180
181
182 if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
184 if (sx >
f->num_h_slices - sw || sy >
f->num_v_slices - sh)
186
187 fs->slice_x = sx * (
int64_t)
f->width /
f->num_h_slices;
188 fs->slice_y = sy * (
int64_t)
f->height /
f->num_v_slices;
189 fs->slice_width = (sx + sw) * (
int64_t)
f->width /
f->num_h_slices -
fs->slice_x;
190 fs->slice_height = (sy + sh) * (
int64_t)
f->height /
f->num_v_slices -
fs->slice_y;
191
193 (
unsigned)
fs->slice_height <=
f->height);
194 av_assert0 ( (
unsigned)
fs->slice_x + (uint64_t)
fs->slice_width <=
f->width
195 && (
unsigned)
fs->slice_y + (uint64_t)
fs->slice_height <=
f->height);
196
199
200 for (
i = 0;
i <
f->plane_count;
i++) {
203 if (idx >= (
unsigned)
f->quant_table_count) {
205 return -1;
206 }
210
214 }
216 }
217
219 if (ps == 1) {
222 } else if (ps == 2) {
225 } else if (ps == 3) {
227 }
230
232 f->cur->sample_aspect_ratio) < 0) {
234 f->cur->sample_aspect_ratio.num,
235 f->cur->sample_aspect_ratio.den);
236 f->cur->sample_aspect_ratio = (
AVRational){ 0, 1 };
237 }
238
239 if (
fs->version > 3) {
242 if (
fs->slice_coding_mode != 1) {
245 if ((uint64_t)
fs->slice_rct_by_coef + (uint64_t)
fs->slice_rct_ry_coef > 4) {
248 }
249 }
250 }
251
252 return 0;
253 }
254
256 {
263
264 for( si=0;
fs !=
f->slice_context[si]; si ++)
265 ;
266
269
275
278
279 for (
i = 0;
i <
f->plane_count;
i++) {
282
285 memcpy(pdst, psrc, sizeof(*pdst));
288
292 } else {
295 }
296 }
297 }
298
299 fs->slice_rct_by_coef = 1;
300 fs->slice_rct_ry_coef = 1;
301
302 if (
f->version > 2) {
306 fs->slice_x =
fs->slice_y =
fs->slice_height =
fs->slice_width = 0;
307 fs->slice_damaged = 1;
309 }
310 }
315 }
else if (
fs->slice_damaged) {
317 }
318
323
325 if (
f->version == 3 &&
f->micro_version > 1 ||
f->version > 3)
327 fs->ac_byte_count =
f->version > 2 || (!x && !y) ?
fs->c.bytestream -
fs->c.bytestream_start - 1 : 0;
329 fs->c.bytestream_start +
fs->ac_byte_count,
330 (
fs->c.bytestream_end -
fs->c.bytestream_start -
fs->ac_byte_count) * 8);
331 }
332
334 if (
f->colorspace == 0 && (
f->chroma_planes || !
fs->transparency)) {
337 const int cx = x >>
f->chroma_h_shift;
338 const int cy = y >>
f->chroma_v_shift;
340
341 if (
f->chroma_planes) {
344 }
345 if (
fs->transparency)
347 }
else if (
f->colorspace == 0) {
350 }
else if (
f->use32bit) {
356 } else {
362 }
364 int v;
366 v =
fs->c.bytestream_end -
fs->c.bytestream - 2 - 5*
f->ec;
367 if (v) {
369 fs->slice_damaged = 1;
370 }
371 }
372
374
375 return 0;
376 }
377
379 {
380 int v;
383
385
386 for (v = 0;
i < 128; v++) {
388
391
395 }
396 }
397
398 for (
i = 1;
i < 128;
i++)
401
402 return 2 * v - 1;
403 }
404
407 {
410
411 for (
i = 0;
i < 5;
i++) {
418 }
419 }
421 }
422
424 {
429 unsigned crc = 0;
430
431 memset(state2, 128, sizeof(state2));
433
436
438 if (
f->version < 2) {
441 }
442 if (
f->version > 4) {
446 }
447 if (
f->version > 2) {
448 c->bytestream_end -= 4;
450 if (
f->micro_version < 0)
452 }
454
456 for (
i = 1;
i < 256;
i++)
458 }
459
466 f->plane_count = 1 + (
f->chroma_planes ||
f->version<4) +
f->transparency;
469
470 if (
f->chroma_h_shift > 4
U ||
f->chroma_v_shift > 4
U) {
472 f->chroma_h_shift,
f->chroma_v_shift);
474 }
475
476 if (
f->num_h_slices > (
unsigned)
f->width || !
f->num_h_slices ||
477 f->num_v_slices > (
unsigned)
f->height || !
f->num_v_slices
478 ) {
481 }
482
486 }
487
491 f->quant_table_count = 0;
493 }
494
495 for (
i = 0;
i <
f->quant_table_count;
i++) {
497 if (
f->context_count[
i] < 0) {
500 }
501 }
504
505 for (
i = 0;
i <
f->quant_table_count;
i++)
507 for (j = 0; j <
f->context_count[
i]; j++)
509 int pred = j ?
f->initial_states[
i][j - 1][k] : 128;
510 f->initial_states[
i][j][k] =
512 }
513 }
514
515 if (
f->version > 2) {
517 if (
f->micro_version > 2)
519 }
520
521 if (
f->version > 2) {
522 unsigned v;
524 f->avctx->extradata,
f->avctx->extradata_size);
525 if (v ||
f->avctx->extradata_size < 4) {
528 }
529 crc =
AV_RB32(
f->avctx->extradata +
f->avctx->extradata_size - 4);
530 }
531
534 "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d CRC:0x%08X\n",
535 f->version,
f->micro_version,
538 f->avctx->bits_per_raw_sample,
539 f->chroma_planes,
f->chroma_h_shift,
f->chroma_v_shift,
541 f->num_h_slices,
f->num_v_slices,
542 f->quant_table_count,
545 crc
546 );
547 return 0;
548 }
549
551 {
555
557
558 if (
f->version < 2) {
561 if (v >= 2) {
564 }
567
569 for (
i = 1;
i < 256;
i++) {
571 if (st < 1 || st > 255) {
574 }
575 f->state_transition[
i] = st;
576 }
577 }
578
587
588 if (
f->plane_count) {
597 }
598 }
599
604 }
605
612
613 f->plane_count = 2 +
f->transparency;
614 }
615
616 if (
f->colorspace == 0) {
617 if (!
f->transparency && !
f->chroma_planes) {
618 if (
f->avctx->bits_per_raw_sample <= 8)
620 else if (
f->avctx->bits_per_raw_sample == 9) {
621 f->packed_at_lsb = 1;
623 }
else if (
f->avctx->bits_per_raw_sample == 10) {
624 f->packed_at_lsb = 1;
626 }
else if (
f->avctx->bits_per_raw_sample == 12) {
627 f->packed_at_lsb = 1;
629 }
else if (
f->avctx->bits_per_raw_sample == 14) {
630 f->packed_at_lsb = 1;
632 }
else if (
f->avctx->bits_per_raw_sample == 16) {
633 f->packed_at_lsb = 1;
635 }
else if (
f->avctx->bits_per_raw_sample < 16) {
637 } else
639 }
else if (
f->transparency && !
f->chroma_planes) {
640 if (
f->avctx->bits_per_raw_sample <= 8)
642 else
644 }
else if (
f->avctx->bits_per_raw_sample<=8 && !
f->transparency) {
645 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
652 }
653 }
else if (
f->avctx->bits_per_raw_sample <= 8 &&
f->transparency) {
654 switch(16*
f->chroma_h_shift +
f->chroma_v_shift) {
658 }
659 }
else if (
f->avctx->bits_per_raw_sample == 9 && !
f->transparency) {
660 f->packed_at_lsb = 1;
661 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
665 }
666 }
else if (
f->avctx->bits_per_raw_sample == 9 &&
f->transparency) {
667 f->packed_at_lsb = 1;
668 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
672 }
673 }
else if (
f->avctx->bits_per_raw_sample == 10 && !
f->transparency) {
674 f->packed_at_lsb = 1;
675 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
680 }
681 }
else if (
f->avctx->bits_per_raw_sample == 10 &&
f->transparency) {
682 f->packed_at_lsb = 1;
683 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
687 }
688 }
else if (
f->avctx->bits_per_raw_sample == 12 && !
f->transparency) {
689 f->packed_at_lsb = 1;
690 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
695 }
696 }
else if (
f->avctx->bits_per_raw_sample == 12 &&
f->transparency) {
697 f->packed_at_lsb = 1;
698 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
701 }
702 }
else if (
f->avctx->bits_per_raw_sample == 14 && !
f->transparency) {
703 f->packed_at_lsb = 1;
704 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
708 }
709 }
else if (
f->avctx->bits_per_raw_sample == 16 && !
f->transparency){
710 f->packed_at_lsb = 1;
711 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
715 }
716 }
else if (
f->avctx->bits_per_raw_sample == 16 &&
f->transparency){
717 f->packed_at_lsb = 1;
718 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
722 }
723 }
724 }
else if (
f->colorspace == 1) {
725 if (
f->chroma_h_shift ||
f->chroma_v_shift) {
727 "chroma subsampling not supported in this colorspace\n");
729 }
730 if (
f->avctx->bits_per_raw_sample <= 8 && !
f->transparency)
732 else if (
f->avctx->bits_per_raw_sample <= 8 &&
f->transparency)
734 else if (
f->avctx->bits_per_raw_sample == 9 && !
f->transparency)
736 else if (
f->avctx->bits_per_raw_sample == 10 && !
f->transparency)
738 else if (
f->avctx->bits_per_raw_sample == 10 &&
f->transparency)
740 else if (
f->avctx->bits_per_raw_sample == 12 && !
f->transparency)
742 else if (
f->avctx->bits_per_raw_sample == 12 &&
f->transparency)
744 else if (
f->avctx->bits_per_raw_sample == 14 && !
f->transparency)
746 else if (
f->avctx->bits_per_raw_sample == 14 &&
f->transparency)
748 else if (
f->avctx->bits_per_raw_sample == 16 && !
f->transparency) {
751 }
752 else if (
f->avctx->bits_per_raw_sample == 16 &&
f->transparency) {
755 }
756 } else {
759 }
763 }
764
766 f->chroma_h_shift,
f->chroma_v_shift,
f->avctx->pix_fmt);
767 if (
f->version < 2) {
772 }
773 f->slice_count =
f->max_slice_count;
774 }
else if (
f->version < 3) {
776 } else {
777 const uint8_t *p =
c->bytestream_end;
778 for (
f->slice_count = 0;
779 f->slice_count <
MAX_SLICES && 3 + 5*!!
f->ec < p -
c->bytestream_start;
781 int trailer = 3 + 5*!!
f->ec;
783 if (
size + trailer > p -
c->bytestream_start)
784 break;
786 }
787 }
788 if (
f->slice_count > (
unsigned)
MAX_SLICES ||
f->slice_count <= 0 ||
f->slice_count >
f->max_slice_count) {
789 av_log(
f->avctx,
AV_LOG_ERROR,
"slice count %d is invalid (max=%d)\n",
f->slice_count,
f->max_slice_count);
791 }
792
793 for (j = 0; j <
f->slice_count; j++) {
796 fs->packed_at_lsb =
f->packed_at_lsb;
797
798 fs->slice_damaged = 0;
799
800 if (
f->version == 2) {
805
806 if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
808 if (sx >
f->num_h_slices - sw || sy >
f->num_v_slices - sh)
810
811 fs->slice_x = sx * (
int64_t)
f->width /
f->num_h_slices;
812 fs->slice_y = sy * (
int64_t)
f->height /
f->num_v_slices;
813 fs->slice_width = (sx + sw) * (
int64_t)
f->width /
f->num_h_slices -
fs->slice_x;
814 fs->slice_height = (sy + sh) * (
int64_t)
f->height /
f->num_v_slices -
fs->slice_y;
815
817 (
unsigned)
fs->slice_height <=
f->height);
818 av_assert0 ( (
unsigned)
fs->slice_x + (uint64_t)
fs->slice_width <=
f->width
819 && (
unsigned)
fs->slice_y + (uint64_t)
fs->slice_height <=
f->height);
820 }
821
822 for (
i = 0;
i <
f->plane_count;
i++) {
824
825 if (
f->version == 2) {
827 if (idx >= (
unsigned)
f->quant_table_count) {
829 "quant_table_index out of range\n");
831 }
836 } else {
838 }
839
840 if (
f->version <= 2) {
845 }
847 }
848 }
849 }
850 return 0;
851 }
852
854 {
857
860
863 if (!
f->picture.f || !
f->last_picture.f)
865
868
871
872 return 0;
873 }
874
877 {
878 uint8_t *buf = avpkt->
data;
879 int buf_size = avpkt->
size;
883 uint8_t keystate = 128;
884 uint8_t *buf_p;
886
887 if (
f->last_picture.f)
890
891 f->cur = p =
f->picture.f;
892
894 /* we have interlaced material flagged in container */
898 }
899
903
911 } else {
912 if (!
f->key_frame_ok) {
914 "Cannot decode non-keyframe without valid keyframe\n");
916 }
918 }
919
923 } else {
925 int s = 1 +
w / (1<<23);
926
928
933 }
934
938
942
944
945 buf_p = buf + buf_size;
946 for (
i =
f->slice_count - 1;
i >= 0;
i--) {
948 int trailer = 3 + 5*!!
f->ec;
949 int v;
950
951 if (
i ||
f->version > 2) {
952 if (trailer > buf_p - buf) v = INT_MAX;
953 else v =
AV_RB24(buf_p-trailer) + trailer;
954 }
else v = buf_p -
c->bytestream_start;
955 if (buf_p -
c->bytestream_start < v) {
959 }
960 buf_p -= v;
961
964 if (crc) {
971 } else {
973 }
974 fs->slice_damaged = 1;
975 }
978 }
979 }
980
983 } else
984 fs->c.bytestream_end = buf_p + v;
985
987 }
988
991 &
f->slice_context[0],
994 sizeof(void*));
995
996 for (
i =
f->slice_count - 1;
i >= 0;
i--) {
998 int j;
999 if (
fs->slice_damaged &&
f->last_picture.f->data[0]) {
1001 const uint8_t *
src[4];
1002 uint8_t *dst[4];
1004 for (j = 0; j <
desc->nb_components; j++) {
1005 int pixshift =
desc->comp[j].depth > 8;
1006 int sh = (j == 1 || j == 2) ?
f->chroma_h_shift : 0;
1007 int sv = (j == 1 || j == 2) ?
f->chroma_v_shift : 0;
1009 (
fs->slice_y >> sv) + ((
fs->slice_x >> sh) << pixshift);
1010 src[j] =
f->last_picture.f->data[j] +
f->last_picture.f->linesize[j] *
1011 (
fs->slice_y >> sv) + ((
fs->slice_x >> sh) << pixshift);
1012
1013 }
1015 dst[1] = p->
data[1];
1016 src[1] =
f->last_picture.f->data[1];
1017 }
1019 f->last_picture.f->linesize,
1023 }
1024 }
1026
1027 if (
f->last_picture.f)
1031
1032 *got_frame = 1;
1033
1034 return buf_size;
1035 }
1036
1039 {
1049
1054
1062 }
1063 }
1064
1065 #if HAVE_THREADS
1067 {
1071
1073 return 0;
1074
1080
1085 }
1088
1090
1091
1096 }
1097
1099
1100 return 0;
1101 }
1102 #endif
1103
1105 {
1107
1111 }
1112
1113 if (
s->last_picture.f) {
1116 }
1118 }
1119
1134 };
#define AV_PIX_FMT_YUVA422P16
static int read_extra_header(FFV1Context *f)
#define AV_PIX_FMT_GBRAP16
#define AV_LOG_WARNING
Something somehow does not look correct.
static void update_vlc_state(VlcState *const state, const int v)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int decode_slice(AVCodecContext *c, void *arg)
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
static int is_input_end(FFV1Context *s)
int context_count[MAX_QUANT_TABLES]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_PIX_FMT_YUVA422P9
static int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (ffv1).
This structure describes decoded (raw) audio or video data.
av_cold int ff_ffv1_common_init(AVCodecContext *avctx)
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
enum AVFieldOrder field_order
Field order.
int step
Number of elements between 2 horizontally consecutive pixels.
#define AV_PIX_FMT_YUV420P10
uint8_t(* state)[CONTEXT_SIZE]
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
struct FFV1Context * slice_context[MAX_SLICES]
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
#define AC_RANGE_CUSTOM_TAB
#define AV_PIX_FMT_YUVA422P10
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
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 ff_thread_await_progress() has been called on them. reget_buffer() and buffer age optimizations no longer work. *The contents of buffers must not be written to after ff_thread_report_progress() has been called on them. This includes draw_edges(). Porting codecs to frame threading
#define FF_DEBUG_PICT_INFO
static av_always_inline int RENAME() decode_line(FFV1Context *s, int w, TYPE *sample[2], int plane_index, int bits)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_PIX_FMT_YUVA420P9
@ AV_FIELD_TT
Top coded_first, top displayed first.
AVCodec p
The public AVCodec.
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
static av_cold int ffv1_decode_close(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_GRAY16
static av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed)
@ AV_FIELD_TB
Top coded first, bottom displayed first.
void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
#define AV_PIX_FMT_GBRAP10
#define FF_CODEC_DECODE_CB(func)
#define AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
PlaneContext plane[MAX_PLANES]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
struct FFV1Context * fsrc
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int read_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256])
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
static av_always_inline int fold(int diff, int bits)
int ac
1=range coder <-> 0=golomb rice
static int get_vlc_symbol(GetBitContext *gb, VlcState *const state, int bits)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define CODEC_LONG_NAME(str)
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
#define AV_PIX_FMT_GRAY10
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static const int16_t quant_table[64]
#define AV_PIX_FMT_GBRP16
static int read_header(FFV1Context *f)
static av_noinline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define fs(width, name, subs,...)
Rational number (pair of numerator and denominator).
@ AV_PICTURE_TYPE_I
Intra.
const FFCodec ff_ffv1_decoder
uint8_t state_transition[256]
void ff_thread_release_ext_buffer(ThreadFrame *f)
Unref a ThreadFrame.
#define AV_PIX_FMT_YUV440P10
#define UPDATE_THREAD_CONTEXT(func)
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
enum AVPictureType pict_type
Picture type of the frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define AV_PIX_FMT_YUV422P12
av_cold int ff_ffv1_close(AVCodecContext *avctx)
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define AV_PIX_FMT_YUV444P12
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_PIX_FMT_YUVA444P10
static int decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride)
static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, const FFV1Context *fsrc)
av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_PIX_FMT_GBRP12
#define av_malloc_array(a, b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
const char * name
Name of the codec implementation.
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 update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies
static int get_rac(RangeCoder *c, uint8_t *const state)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around ff_get_buffer() for frame-multithreaded codecs.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_PIX_FMT_YUV444P9
#define MAX_CONTEXT_INPUTS
static const float pred[4]
#define FFSWAP(type, a, b)
#define AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_YUVA444P9
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 ff_thread_finish_setup() afterwards. If some code can 't be moved
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
int ff_ffv1_allocate_initial_states(FFV1Context *f)
static int RENAME() decode_rgb_frame(FFV1Context *s, uint8_t *src[4], int w, int h, int stride[4])
main external API structure.
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
static av_cold int decode_init(AVCodecContext *avctx)
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AV_PIX_FMT_YUVA422P12
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const struct @386 planes[]
This structure stores compressed data.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int width
picture width / height.
av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
const uint8_t ff_log2_run[41]
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
#define AV_PIX_FMT_GRAY12
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
void av_image_copy(uint8_t *const dst_data[4], const int dst_linesizes[4], const uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
static int decode_slice_header(const FFV1Context *f, FFV1Context *fs)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
Generated on Thu Sep 26 2024 23:14:56 for FFmpeg by
doxygen
1.8.17