38 #define COPY_PICTURE(dst, src) \ 41 (dst)->f.extended_data = (dst)->f.data;\ 42 (dst)->tf.f = &(dst)->f;\ 48 for (i = 0; i < 4; ++i) {
79 while ((i[0] < len || i[1] < len) && index < def_len) {
80 while (i[0] < len && !(in[i[0]] && (in[i[0]]->reference & sel)))
82 while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3))))
84 if (i[0] < len && index < def_len) {
88 if (i[1] < len && index < def_len) {
103 best_poc = dir ? INT_MIN : INT_MAX;
105 for (i = 0; i <
len; i++) {
106 const int poc = src[i]->
poc;
107 if (((poc > limit) ^ dir) && ((poc < best_poc) ^ dir)) {
109 sorted[out_i] = src[i];
112 if (best_poc == (dir ? INT_MIN : INT_MAX))
114 limit = sorted[out_i++]->
poc - dir;
133 for (list = 0; list < 2; list++) {
144 if (len < h->ref_count[list])
149 if (lens[0] == lens[1] && lens[1] > 1) {
150 for (i = 0; i < lens[0] &&
167 if (len < h->ref_count[0])
217 int list,
index, pic_structure, i;
222 for (list = 0; list < h->
list_count; list++) {
229 for (index = 0; ; index++) {
235 if (modification_of_pic_nums_idc == 3)
243 switch (modification_of_pic_nums_idc) {
251 "abs_diff_pic_num overflow\n");
255 if (modification_of_pic_nums_idc == 0)
256 pred -= abs_diff_pic_num;
258 pred += abs_diff_pic_num;
283 "long_term_pic_idx overflow\n");
288 if (ref && (ref->
reference & pic_structure)) {
299 "illegal modification_of_pic_nums_idc %u\n",
300 modification_of_pic_nums_idc);
306 "reference picture missing during reorder\n");
309 for (i = index; i + 1 < h->
ref_count[list]; i++) {
314 for (; i >
index; i--) {
325 for (list = 0; list < h->
list_count; list++) {
326 for (index = 0; index < h->
ref_count[list]; index++) {
343 for (list = 0; list < 2; list++) {
344 for (i = 0; i < h->
ref_count[list]; i++) {
348 for (j = 0; j < 3; j++)
349 field[0].f.linesize[j] <<= 1;
353 for (j = 0; j < 3; j++)
354 field[1].f.data[j] += frame->
f.
linesize[j];
360 for (j = 0; j < 2; j++) {
426 assert(i >= 0 && i < h->short_ref_count);
480 for (i = 0; i < 16; i++) {
516 for (i = 0; i < 16; i++) {
530 for (i = 0; i < n_mmcos; i++) {
531 if (mmco1[i].opcode != mmco2[i].opcode)
541 int mmco_index = 0, i = 0;
561 }
else if (!first_slice && mmco_index >= 0 &&
565 "Inconsistent MMCO state between slices [%d, %d, %d]\n",
575 int current_ref_assigned = 0, err = 0;
581 for (i = 0; i < mmco_count; i++) {
602 switch (mmco[i].opcode) {
657 current_ref_assigned = 1;
660 assert(mmco[i].long_arg <= 16);
662 for (j = mmco[i].long_arg; j < 16; j++) {
670 for (j = 0; j < 16; j++) {
681 if (!current_ref_assigned) {
693 "assignment for second field " 694 "in complementary field pair " 695 "(first field is long term)\n");
722 "number of reference frames (%d+%d) exceeds max (%d; probably " 723 "corrupt input), discarding one\n",
728 for (i = 0; i < 16; ++i)
773 "illegal short ref in memory management control " 774 "operation %d\n", mmco);
782 if (long_arg >= 32 ||
787 "illegal long ref in memory management control " 788 "operation %d\n", opcode);
796 "illegal memory management control operation %d\n",
814 if (first_slice && mmco_index != -1) {
816 }
else if (!first_slice && mmco_index >= 0 &&
820 "Inconsistent MMCO state between slices [%d, %d]\n",
Memory management control operation.
static int pic_num_extract(H264Context *h, int pic_num, int *structure)
Extract structure information about the picture described by pic_num in the current decoding context ...
static int add_sorted(H264Picture **sorted, H264Picture **src, int len, int limit, int dir)
int long_ref
1->long term reference 0->short term reference
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static H264Picture * remove_short(H264Context *h, int frame_num, int ref_mask)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
MMCO mmco[MAX_MMCO_COUNT]
memory management control operations buffer.
int ff_h264_fill_default_ref_list(H264Context *h)
Fill the default_ref_list.
H264Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
void ff_h264_fill_mbaff_ref_list(H264Context *h)
int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
MMCOOpcode
Memory management control operation opcode.
static int build_def_list(H264Picture *def, int def_len, H264Picture **in, int len, int is_long, int sel)
#define FF_ARRAY_ELEMS(a)
H264Picture * long_ref[32]
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
static void pic_as_field(H264Picture *pic, const int parity)
void ff_h264_remove_all_refs(H264Context *h)
int short_pic_num
pic_num without wrapping (pic_num & max_pic_num)
int luma_weight[48][2][2]
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, int first_slice)
#define PICT_BOTTOM_FIELD
H264Picture default_ref_list[2][32]
base reference list for all slices of a coded picture
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
int chroma_weight[48][2][2][2]
H.264 / AVC / MPEG4 part10 codec.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_log(void *avcl, int level, const char *fmt,...)
#define COPY_PICTURE(dst, src)
int frame_num
frame_num (raw frame_num from slice header)
static int unreference_pic(H264Context *h, H264Picture *pic, int refmask)
Mark a picture as no longer needed for reference.
int ref_frame_count
num_ref_frames
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int split_field_copy(H264Picture *dest, H264Picture *src, int parity, int id_add)
int long_ref_count
number of actual long term references
H264Picture ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
int max_pic_num
max_frame_num or 2 * max_frame_num for field pics.
int curr_pic_num
frame_num for frames or 2 * frame_num + 1 for field pics.
static void remove_short_at_index(H264Context *h, int i)
Remove a picture from the short term reference list by its index in that list.
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
static H264Picture * find_short(H264Context *h, int frame_num, int *idx)
Find a H264Picture in the short term reference list by frame number.
static const float pred[4]
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
Execute the reference picture marking (memory management control operations).
Libavcodec external API header.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
H264Picture * short_ref[32]
int field_poc[2]
top/bottom POC
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
int mmco_reset
MMCO_RESET set this 1.
static H264Picture * remove_long(H264Context *h, int i, int ref_mask)
Remove a picture from the long term reference list by its index in that list.
H264Picture * cur_pic_ptr
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int pic_id
pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num) ...
common internal api header.
int long_arg
index, pic_num, or num long refs depending on opcode
static void print_long_term(H264Context *h)
print long term list
static void print_short_term(H264Context *h)
print short term list
int short_ref_count
number of actual short term references