Go to the documentation of this file.
85 while (
i[0] <
len && !(in[
i[0]] && (in[
i[0]]->reference & sel)))
87 while (
i[1] <
len && !(in[
i[1]] && (in[
i[1]]->reference & (sel ^ 3))))
111 best_poc = dir ? INT_MIN : INT_MAX;
113 for (
i = 0;
i <
len;
i++) {
114 const int poc =
src[
i]->poc;
115 if (((poc >
limit) ^ dir) && ((poc < best_poc) ^ dir)) {
117 sorted[out_i] =
src[
i];
120 if (best_poc == (dir ? INT_MIN : INT_MAX))
130 return (
h->cur_pic_ptr->f->width !=
f->width ||
131 h->cur_pic_ptr->f->height !=
f->height ||
132 h->cur_pic_ptr->f->format !=
f->format);
148 cur_poc =
h->cur_pic_ptr->poc;
156 sorted,
len, 0,
h->picture_structure);
159 h->long_ref, 16, 1,
h->picture_structure);
162 if (len < sl->ref_count[
list])
167 if (lens[0] == lens[1] && lens[1] > 1) {
168 for (
i = 0;
i < lens[0] &&
177 h->short_ref,
h->short_ref_count, 0,
h->picture_structure);
180 h-> long_ref, 16, 1,
h->picture_structure);
183 if (len < sl->ref_count[0])
188 ff_tlog(
h->avctx,
"List0: %s fn:%d 0x%p\n",
195 ff_tlog(
h->avctx,
"List1: %s fn:%d 0x%p\n",
225 for (
i = 0;
i <
h->short_ref_count;
i++) {
241 for (
i = 0;
i < 16;
i++) {
263 *structure =
h->picture_structure;
284 for (j = 0; j < 3; j++)
285 field[0].linesize[j] <<= 1;
291 for (j = 0; j < 3; j++)
318 switch (modification_of_pic_nums_idc) {
321 const unsigned int abs_diff_pic_num =
val + 1;
326 "abs_diff_pic_num overflow\n");
330 if (modification_of_pic_nums_idc == 0)
331 pred -= abs_diff_pic_num;
333 pred += abs_diff_pic_num;
338 for (
i =
h->short_ref_count - 1;
i >= 0;
i--) {
339 ref =
h->short_ref[
i];
340 assert(
ref->reference);
341 assert(!
ref->long_ref);
342 if (
ref->frame_num == frame_num &&
343 (
ref->reference & pic_structure))
356 if (long_idx > 31
U) {
358 "long_term_pic_idx overflow\n");
361 ref =
h->long_ref[long_idx];
362 assert(!(
ref && !
ref->reference));
363 if (
ref && (
ref->reference & pic_structure)) {
364 ref->pic_id = pic_id;
365 assert(
ref->long_ref);
378 i < 0 ?
"reference picture missing during reorder\n" :
379 "mismatching reference\n"
406 h->last_pocs[
i] = INT_MIN;
407 if (
h->default_ref[
list].parent
415 int list2 = (
list+j)&1;
416 if (
h->default_ref[list2].parent && !
h->default_ref[list2].parent->gray
456 "illegal modification_of_pic_nums_idc %u\n",
486 for(
i = 0;
h->delayed_pic[
i];
i++)
487 if(pic ==
h->delayed_pic[
i]){
507 for (
i = 0;
i <
h->short_ref_count;
i++) {
527 assert(
i >= 0 && i < h->short_ref_count);
529 if (--
h->short_ref_count)
530 memmove(&
h->short_ref[
i], &
h->short_ref[
i + 1],
563 pic =
h->long_ref[
i];
566 assert(
h->long_ref[
i]->long_ref == 1);
567 h->long_ref[
i]->long_ref = 0;
580 for (
i = 0;
i < 16;
i++) {
583 assert(
h->long_ref_count == 0);
585 if (
h->short_ref_count && !
h->last_pic_for_ec.f->data[0]) {
590 for (
i = 0;
i <
h->short_ref_count;
i++) {
594 h->short_ref_count = 0;
596 memset(
h->default_ref, 0,
sizeof(
h->default_ref));
601 MMCO *mmco =
h->mmco;
604 if (
h->short_ref_count &&
605 h->long_ref_count +
h->short_ref_count >=
h->ps.sps->ref_frame_count &&
608 mmco[0].
short_pic_num =
h->short_ref[
h->short_ref_count - 1]->frame_num;
618 h->nb_mmco = nb_mmco;
623 MMCO *mmco =
h->mmco;
626 int pps_ref_count[2] = {0};
627 int current_ref_assigned = 0, err = 0;
636 if (!
h->explicit_ref_marking)
638 mmco_count =
h->nb_mmco;
643 for (
i = 0;
i < mmco_count;
i++) {
647 h->mmco[
i].short_pic_num,
h->mmco[
i].long_arg);
656 h->long_ref[mmco[
i].
long_arg]->frame_num != frame_num) {
664 switch (mmco[
i].opcode) {
668 h->mmco[
i].short_pic_num,
h->short_ref_count);
684 pic =
h->long_ref[j];
698 if (
h->short_ref[0] ==
h->cur_pic_ptr) {
699 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to short and long at the same time\n");
704 if (
h->cur_pic_ptr->long_ref) {
706 if (
h->long_ref[j] ==
h->cur_pic_ptr) {
707 if (j != mmco[
i].long_arg)
708 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to 2 long term references\n");
714 if (
h->long_ref[mmco[
i].
long_arg] !=
h->cur_pic_ptr) {
723 h->cur_pic_ptr->reference |=
h->picture_structure;
724 current_ref_assigned = 1;
727 assert(mmco[
i].long_arg <= 16);
729 for (j = mmco[
i].long_arg; j < 16; j++) {
734 while (
h->short_ref_count) {
737 for (j = 0; j < 16; j++) {
740 h->poc.frame_num =
h->cur_pic_ptr->frame_num = 0;
742 h->cur_pic_ptr->mmco_reset = 1;
744 h->last_pocs[j] = INT_MIN;
750 if (!current_ref_assigned) {
757 if (
h->short_ref_count &&
h->short_ref[0] ==
h->cur_pic_ptr) {
759 h->cur_pic_ptr->reference |=
h->picture_structure;
760 }
else if (
h->cur_pic_ptr->long_ref) {
762 "assignment for second field "
763 "in complementary field pair "
764 "(first field is long term)\n");
773 if (
h->short_ref_count)
774 memmove(&
h->short_ref[1], &
h->short_ref[0],
777 h->short_ref[0] =
h->cur_pic_ptr;
778 h->short_ref_count++;
779 h->cur_pic_ptr->reference |=
h->picture_structure;
783 if (
h->long_ref_count +
h->short_ref_count >
FFMAX(
h->ps.sps->ref_frame_count, 1)) {
790 "number of reference frames (%d+%d) exceeds max (%d; probably "
791 "corrupt input), discarding one\n",
792 h->long_ref_count,
h->short_ref_count,
h->ps.sps->ref_frame_count);
795 if (
h->long_ref_count && !
h->short_ref_count) {
796 for (
i = 0;
i < 16; ++
i)
803 pic =
h->short_ref[
h->short_ref_count - 1];
808 for (
i = 0;
i<
h->short_ref_count;
i++) {
809 pic =
h->short_ref[
i];
810 if (pic->invalid_gap) {
811 int d =
av_mod_uintp2(
h->cur_pic_ptr->frame_num - pic->frame_num,
h->ps.sps->log2_max_frame_num);
812 if (
d >
h->ps.sps->ref_frame_count)
821 if (
h->ps.pps_list[
i]) {
823 pps_ref_count[0] =
FFMAX(pps_ref_count[0],
pps->ref_count[0]);
824 pps_ref_count[1] =
FFMAX(pps_ref_count[1],
pps->ref_count[1]);
830 &&
h->long_ref_count==0
831 && (
h->short_ref_count<=2
832 || pps_ref_count[0] <= 2 && pps_ref_count[1] <= 1 &&
h->avctx->has_b_frames
833 || pps_ref_count[0] <= 1 + (
h->picture_structure !=
PICT_FRAME) && pps_ref_count[1] <= 1)
834 && pps_ref_count[0]<=2 + (
h->picture_structure !=
PICT_FRAME) + (2*!
h->has_recovery_point)
837 if(!
h->avctx->has_b_frames)
875 if (long_arg >= 32 ||
880 "illegal long ref in memory management control "
881 "operation %d\n", opcode);
890 "illegal memory management control operation %d\n",
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.
int nb_ref_modifications[2]
int long_arg
index, pic_num, or num long refs depending on opcode
static int mismatches_ref(const H264Context *h, const H264Picture *pic)
#define AV_EF_EXPLODE
abort decoding on minor error detection
static void print_long_term(const H264Context *h)
print long term list
int ff_h264_ref_picture(H264Picture *dst, const H264Picture *src)
This structure describes decoded (raw) audio or video data.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
#define PICT_BOTTOM_FIELD
static int build_def_list(H264Ref *def, int def_len, H264Picture *const *in, int len, int is_long, int sel)
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
MMCOOpcode
Memory management control operation opcode.
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int frame_num
frame_num (raw frame_num from slice header)
static double val(void *priv, double ch)
struct H264SliceContext::@85 ref_modifications[2][32]
#define FRAME_RECOVERED_HEURISTIC
Recovery point detected by heuristic.
static H264Picture * find_short(H264Context *h, int frame_num, int *idx)
Find a H264Picture in the short term reference list by frame number.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
int ff_h264_execute_ref_pic_marking(H264Context *h)
Execute the reference picture marking (memory management control operations).
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb, const H2645NAL *nal, void *logctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_h264_remove_all_refs(H264Context *h)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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 field
static int pic_num_extract(const H264Context *h, int pic_num, int *structure)
Extract structure information about the picture described by pic_num in the current decoding context ...
int short_pic_num
pic_num without wrapping (pic_num & max_pic_num)
const H264Picture * parent
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
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 list
static void print_short_term(const H264Context *h)
print short term list
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output.
int pic_id
pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num)
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
static int unreference_pic(H264Context *h, H264Picture *pic, int refmask)
Mark a picture as no longer needed for reference.
int av_buffer_get_ref_count(const AVBufferRef *buf)
static void skip_bits1(GetBitContext *s)
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
#define i(width, name, range_min, range_max)
static void ref_from_h264pic(H264Ref *dst, const H264Picture *src)
static double limit(double x)
static const float pred[4]
#define FFSWAP(type, a, b)
static H264Picture * remove_short(H264Context *h, int frame_num, int ref_mask)
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
static void generate_sliding_window_mmcos(H264Context *h)
int field_poc[2]
top/bottom POC
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
MMCO mmco[H264_MAX_MMCO_COUNT]
static int add_sorted(H264Picture **sorted, H264Picture *const *src, int len, int limit, int dir)
static int split_field_copy(H264Ref *dest, const H264Picture *src, int parity, int id_add)
void ff_h264_unref_picture(H264Picture *pic)
static int ref[MAX_W *MAX_W]
static void h264_fill_mbaff_ref_list(H264SliceContext *sl)
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
Memory management control operation.
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
static void pic_as_field(H264Ref *pic, const int parity)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int long_ref
1->long term reference 0->short term reference