Go to the documentation of this file.
84 while (
i[0] <
len && !(in[
i[0]] && (in[
i[0]]->reference & sel)))
86 while (
i[1] <
len && !(in[
i[1]] && (in[
i[1]]->reference & (sel ^ 3))))
110 best_poc = dir ? INT_MIN : INT_MAX;
112 for (
i = 0;
i <
len;
i++) {
113 const int poc =
src[
i]->poc;
114 if (((poc >
limit) ^ dir) && ((poc < best_poc) ^ dir)) {
116 sorted[out_i] =
src[
i];
119 if (best_poc == (dir ? INT_MIN : INT_MAX))
129 return (
h->cur_pic_ptr->f->width !=
f->width ||
130 h->cur_pic_ptr->f->height !=
f->height ||
131 h->cur_pic_ptr->f->format !=
f->format);
147 cur_poc =
h->cur_pic_ptr->poc;
155 sorted,
len, 0,
h->picture_structure);
158 h->long_ref, 16, 1,
h->picture_structure);
161 if (len < sl->ref_count[
list])
166 if (lens[0] == lens[1] && lens[1] > 1) {
167 for (
i = 0;
i < lens[0] &&
176 h->short_ref,
h->short_ref_count, 0,
h->picture_structure);
179 h-> long_ref, 16, 1,
h->picture_structure);
182 if (len < sl->ref_count[0])
187 ff_tlog(
h->avctx,
"List0: %s fn:%d 0x%p\n",
194 ff_tlog(
h->avctx,
"List1: %s fn:%d 0x%p\n",
224 for (
i = 0;
i <
h->short_ref_count;
i++) {
240 for (
i = 0;
i < 16;
i++) {
262 *structure =
h->picture_structure;
283 for (j = 0; j < 3; j++)
284 field[0].linesize[j] <<= 1;
290 for (j = 0; j < 3; j++)
317 switch (modification_of_pic_nums_idc) {
320 const unsigned int abs_diff_pic_num =
val + 1;
325 "abs_diff_pic_num overflow\n");
329 if (modification_of_pic_nums_idc == 0)
330 pred -= abs_diff_pic_num;
332 pred += abs_diff_pic_num;
337 for (
i =
h->short_ref_count - 1;
i >= 0;
i--) {
338 ref =
h->short_ref[
i];
339 assert(
ref->reference);
340 assert(!
ref->long_ref);
341 if (
ref->frame_num == frame_num &&
342 (
ref->reference & pic_structure))
355 if (long_idx > 31
U) {
357 "long_term_pic_idx overflow\n");
360 ref =
h->long_ref[long_idx];
361 assert(!(
ref && !
ref->reference));
362 if (
ref && (
ref->reference & pic_structure)) {
363 ref->pic_id = pic_id;
364 assert(
ref->long_ref);
377 i < 0 ?
"reference picture missing during reorder\n" :
378 "mismatching reference\n"
405 h->last_pocs[
i] = INT_MIN;
406 if (
h->default_ref[
list].parent
444 "illegal modification_of_pic_nums_idc %u\n",
474 for(
i = 0;
h->delayed_pic[
i];
i++)
475 if(pic ==
h->delayed_pic[
i]){
495 for (
i = 0;
i <
h->short_ref_count;
i++) {
515 assert(
i >= 0 && i < h->short_ref_count);
517 if (--
h->short_ref_count)
518 memmove(&
h->short_ref[
i], &
h->short_ref[
i + 1],
551 pic =
h->long_ref[
i];
554 assert(
h->long_ref[
i]->long_ref == 1);
555 h->long_ref[
i]->long_ref = 0;
568 for (
i = 0;
i < 16;
i++) {
571 assert(
h->long_ref_count == 0);
573 if (
h->short_ref_count && !
h->last_pic_for_ec.f->data[0]) {
578 for (
i = 0;
i <
h->short_ref_count;
i++) {
582 h->short_ref_count = 0;
584 memset(
h->default_ref, 0,
sizeof(
h->default_ref));
589 MMCO *mmco =
h->mmco;
592 if (
h->short_ref_count &&
593 h->long_ref_count +
h->short_ref_count >=
h->ps.sps->ref_frame_count &&
596 mmco[0].
short_pic_num =
h->short_ref[
h->short_ref_count - 1]->frame_num;
606 h->nb_mmco = nb_mmco;
611 MMCO *mmco =
h->mmco;
614 int pps_ref_count[2] = {0};
615 int current_ref_assigned = 0, err = 0;
624 if (!
h->explicit_ref_marking)
626 mmco_count =
h->nb_mmco;
631 for (
i = 0;
i < mmco_count;
i++) {
635 h->mmco[
i].short_pic_num,
h->mmco[
i].long_arg);
644 h->long_ref[mmco[
i].
long_arg]->frame_num != frame_num) {
652 switch (mmco[
i].opcode) {
656 h->mmco[
i].short_pic_num,
h->short_ref_count);
672 pic =
h->long_ref[j];
686 if (
h->short_ref[0] ==
h->cur_pic_ptr) {
687 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to short and long at the same time\n");
692 if (
h->cur_pic_ptr->long_ref) {
694 if (
h->long_ref[j] ==
h->cur_pic_ptr) {
695 if (j != mmco[
i].long_arg)
696 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to 2 long term references\n");
702 if (
h->long_ref[mmco[
i].
long_arg] !=
h->cur_pic_ptr) {
711 h->cur_pic_ptr->reference |=
h->picture_structure;
712 current_ref_assigned = 1;
715 assert(mmco[
i].long_arg <= 16);
717 for (j = mmco[
i].long_arg; j < 16; j++) {
722 while (
h->short_ref_count) {
725 for (j = 0; j < 16; j++) {
728 h->poc.frame_num =
h->cur_pic_ptr->frame_num = 0;
730 h->cur_pic_ptr->mmco_reset = 1;
732 h->last_pocs[j] = INT_MIN;
738 if (!current_ref_assigned) {
745 if (
h->short_ref_count &&
h->short_ref[0] ==
h->cur_pic_ptr) {
747 h->cur_pic_ptr->reference |=
h->picture_structure;
748 }
else if (
h->cur_pic_ptr->long_ref) {
750 "assignment for second field "
751 "in complementary field pair "
752 "(first field is long term)\n");
761 if (
h->short_ref_count)
762 memmove(&
h->short_ref[1], &
h->short_ref[0],
765 h->short_ref[0] =
h->cur_pic_ptr;
766 h->short_ref_count++;
767 h->cur_pic_ptr->reference |=
h->picture_structure;
771 if (
h->long_ref_count +
h->short_ref_count >
FFMAX(
h->ps.sps->ref_frame_count, 1)) {
778 "number of reference frames (%d+%d) exceeds max (%d; probably "
779 "corrupt input), discarding one\n",
780 h->long_ref_count,
h->short_ref_count,
h->ps.sps->ref_frame_count);
783 if (
h->long_ref_count && !
h->short_ref_count) {
784 for (
i = 0;
i < 16; ++
i)
791 pic =
h->short_ref[
h->short_ref_count - 1];
796 for (
i = 0;
i<
h->short_ref_count;
i++) {
797 pic =
h->short_ref[
i];
798 if (pic->invalid_gap) {
799 int d =
av_mod_uintp2(
h->cur_pic_ptr->frame_num - pic->frame_num,
h->ps.sps->log2_max_frame_num);
800 if (
d >
h->ps.sps->ref_frame_count)
809 if (
h->ps.pps_list[
i]) {
810 const PPS *
pps = (
const PPS *)
h->ps.pps_list[
i]->data;
811 pps_ref_count[0] =
FFMAX(pps_ref_count[0],
pps->ref_count[0]);
812 pps_ref_count[1] =
FFMAX(pps_ref_count[1],
pps->ref_count[1]);
818 &&
h->long_ref_count==0
819 && (
h->short_ref_count<=2
820 || pps_ref_count[0] <= 2 && pps_ref_count[1] <= 1 &&
h->avctx->has_b_frames
821 || pps_ref_count[0] <= 1 + (
h->picture_structure !=
PICT_FRAME) && pps_ref_count[1] <= 1)
822 && pps_ref_count[0]<=2 + (
h->picture_structure !=
PICT_FRAME) + (2*!
h->has_recovery_point)
824 h->cur_pic_ptr->recovered |= 1;
825 if(!
h->avctx->has_b_frames)
863 if (long_arg >= 32 ||
868 "illegal long ref in memory management control "
869 "operation %d\n", opcode);
878 "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.
void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
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
static int split_field_copy(H264Ref *dest, H264Picture *src, int parity, int id_add)
static void ref_from_h264pic(H264Ref *dst, 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)
#define FRAME_RECOVERED_SEI
Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames...
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)
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)
@ 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)
struct H264SliceContext::@78 ref_modifications[2][32]
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 double limit(double x)
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
static const float pred[4]
#define FFSWAP(type, a, b)
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
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 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)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int long_ref
1->long term reference 0->short term reference