28 #include "libavutil/avassert.h"
36 #define COPY_PICTURE(dst, src) \
39 (dst)->f.extended_data = (dst)->f.data;\
40 (dst)->tf.f = &(dst)->f;\
46 for (i = 0; i < 4; ++i) {
76 while (i[0] < len || i[1] < len) {
77 while (i[0] < len && !(in[i[0]] && (in[i[0]]->reference & sel)))
79 while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3))))
100 best_poc = dir ? INT_MIN : INT_MAX;
102 for (i = 0; i <
len; i++) {
103 const int poc = src[i]->
poc;
104 if (((poc > limit) ^ dir) && ((poc < best_poc) ^ dir)) {
106 sorted[out_i] = src[i];
109 if (best_poc == (dir ? INT_MIN : INT_MAX))
111 limit = sorted[out_i++]->
poc - dir;
130 for (list = 0; list < 2; list++) {
138 if (len < h->ref_count[list])
143 if (lens[0] == lens[1] && lens[1] > 1) {
156 if (len < h->ref_count[0])
206 int list,
index, pic_structure, i;
211 for (list = 0; list < h->
list_count; list++) {
218 for (index = 0; ; index++) {
224 if (reordering_of_pic_nums_idc == 3)
232 if (reordering_of_pic_nums_idc < 3) {
233 if (reordering_of_pic_nums_idc < 2) {
242 if (reordering_of_pic_nums_idc == 0)
243 pred -= abs_diff_pic_num;
245 pred += abs_diff_pic_num;
272 if (ref && (ref->
reference & pic_structure)) {
285 for (i = index; i + 1 < h->
ref_count[list]; i++) {
290 for (; i >
index; i--) {
305 for (list = 0; list < h->
list_count; list++) {
306 for (index = 0; index < h->
ref_count[list]; index++) {
329 for (list = 0; list < h->
list_count; list++) {
330 for (i = 0; i < h->
ref_count[list]; i++) {
334 for (j = 0; j < 3; j++)
335 field[0].f.linesize[j] <<= 1;
339 for (j = 0; j < 3; j++)
340 field[1].f.data[j] += frame->
f.
linesize[j];
346 for (j = 0; j < 2; j++) {
412 assert(i >= 0 && i < h->short_ref_count);
466 for (i = 0; i < 16; i++) {
505 for (i = 0; i < 16; i++) {
519 for (i = 0; i < n_mmcos; i++) {
520 if (mmco1[i].opcode != mmco2[i].opcode) {
522 mmco1[i].opcode, mmco2[i].opcode, i);
533 int mmco_index = 0, i;
551 }
else if (!first_slice && mmco_index >= 0 &&
555 "Inconsistent MMCO state between slices [%d, %d]\n",
565 int current_ref_assigned = 0, err = 0;
571 for (i = 0; i < mmco_count; i++) {
592 switch (mmco[i].opcode) {
629 for(j=0; j<16; j++) {
648 current_ref_assigned = 1;
651 assert(mmco[i].long_arg <= 16);
653 for (j = mmco[i].long_arg; j < 16; j++) {
661 for (j = 0; j < 16; j++) {
674 if (!current_ref_assigned) {
686 "assignment for second field "
687 "in complementary field pair "
688 "(first field is long term)\n");
714 "number of reference frames (%d+%d) exceeds max (%d; probably "
715 "corrupt input), discarding one\n",
720 for (i = 0; i < 16; ++i)
772 "illegal short ref in memory management control "
773 "operation %d\n", mmco);
781 if (long_arg >= 32 ||
786 "illegal long ref in memory management control "
787 "operation %d\n", opcode);
795 "illegal memory management control operation %d\n",
813 if (first_slice && mmco_index != -1) {
814 memcpy(h->
mmco, mmco_temp,
sizeof(h->
mmco));
816 }
else if (!first_slice && mmco_index >= 0 &&
820 "Inconsistent MMCO state between slices [%d, %d]\n",
Picture default_ref_list[2][32]
base reference list for all slices of a coded picture
#define PICT_BOTTOM_FIELD
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 ...
int sync
did we had a keyframe or recovery point
static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
MMCO mmco[MAX_MMCO_COUNT]
memory management control operations buffer.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
MMCOOpcode
Memory management control operation opcode.
int mmco_reset
h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET...
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
int long_ref
1->long term reference 0->short term reference
int short_pic_num
pic_num without wrapping (pic_num & max_pic_num)
int luma_weight[48][2][2]
Picture ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
void ff_h264_fill_mbaff_ref_list(H264Context *h)
#define MAX_DELAYED_PIC_COUNT
int chroma_weight[48][2][2][2]
int last_pocs[MAX_DELAYED_PIC_COUNT]
H.264 / AVC / MPEG4 part10 codec.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;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);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define COPY_PICTURE(dst, src)
static void pic_as_field(Picture *pic, const int parity)
Libavcodec external API header.
#define FF_ARRAY_ELEMS(a)
static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir)
int ref_frame_count
num_ref_frames
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static Picture * remove_short(H264Context *h, int frame_num, int ref_mask)
int long_ref_count
number of actual long term references
int frame_num
h264 frame_num (raw frame_num from slice header)
int max_pic_num
max_frame_num or 2 * max_frame_num for field pics.
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
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.
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).
int sync
has been decoded after a keyframe
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
void ff_h264_remove_all_refs(H264Context *h)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int av_buffer_get_ref_count(const AVBufferRef *buf)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add)
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, int first_slice)
static Picture * find_short(H264Context *h, int frame_num, int *idx)
Find a Picture in the short term reference list by frame number.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int field_poc[2]
h264 top/bottom POC
common internal api header.
static Picture * remove_long(H264Context *h, int i, int ref_mask)
Remove a picture from the long term reference list by its index in that list.
int long_arg
index, pic_num, or num long refs depending on opcode
#define AVERROR_INVALIDDATA
int pic_id
h264 pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num) ...
static void print_long_term(H264Context *h)
print long term list
int ff_h264_fill_default_ref_list(H264Context *h)
Fill the default_ref_list.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int unreference_pic(H264Context *h, Picture *pic, int refmask)
Mark a picture as no longer needed for reference.
static void print_short_term(H264Context *h)
print short term list
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)
int short_ref_count
number of actual short term references