Go to the documentation of this file.
52 memcpy(
dst->data,
src->f->data,
sizeof(
dst->data));
53 memcpy(
dst->linesize,
src->f->linesize,
sizeof(
dst->linesize));
54 dst->reference =
src->reference;
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))))
109 int best_poc = dir ? INT_MIN : INT_MAX;
111 for (
int i = 0;
i <
len;
i++) {
112 const int poc =
src[
i]->poc;
113 if (((poc >
limit) ^ dir) && ((poc < best_poc) ^ dir)) {
115 sorted[out_i] =
src[
i];
118 if (best_poc == (dir ? INT_MIN : INT_MAX))
128 return (
h->cur_pic_ptr->f->width !=
f->width ||
129 h->cur_pic_ptr->f->height !=
f->height ||
130 h->cur_pic_ptr->f->format !=
f->format);
145 cur_poc =
h->cur_pic_ptr->poc;
153 sorted,
len, 0,
h->picture_structure);
156 h->long_ref, 16, 1,
h->picture_structure);
159 if (len < sl->ref_count[
list])
164 if (lens[0] == lens[1] && lens[1] > 1) {
166 for (
i = 0;
i < lens[0] &&
175 h->short_ref,
h->short_ref_count, 0,
h->picture_structure);
178 h-> long_ref, 16, 1,
h->picture_structure);
181 if (len < sl->ref_count[0])
186 ff_tlog(
h->avctx,
"List0: %s fn:%d 0x%p\n",
193 ff_tlog(
h->avctx,
"List1: %s fn:%d 0x%p\n",
222 for (uint32_t
i = 0;
i <
h->short_ref_count;
i++) {
237 for (uint32_t
i = 0;
i < 16;
i++) {
259 *structure =
h->picture_structure;
279 for (
int j = 0; j < 3; j++)
280 field[0].linesize[j] <<= 1;
286 for (
int j = 0; j < 3; j++)
308 int i, pic_structure;
311 switch (modification_of_pic_nums_idc) {
314 const unsigned int abs_diff_pic_num =
val + 1;
319 "abs_diff_pic_num overflow\n");
323 if (modification_of_pic_nums_idc == 0)
324 pred -= abs_diff_pic_num;
326 pred += abs_diff_pic_num;
331 for (
i =
h->short_ref_count - 1;
i >= 0;
i--) {
332 ref =
h->short_ref[
i];
333 assert(
ref->reference);
334 assert(!
ref->long_ref);
335 if (
ref->frame_num == frame_num &&
336 (
ref->reference & pic_structure))
349 if (long_idx > 31
U) {
351 "long_term_pic_idx overflow\n");
354 ref =
h->long_ref[long_idx];
355 assert(!(
ref && !
ref->reference));
356 if (
ref && (
ref->reference & pic_structure)) {
357 ref->pic_id = pic_id;
358 assert(
ref->long_ref);
371 i < 0 ?
"reference picture missing during reorder\n" :
372 "mismatching reference\n"
399 h->last_pocs[
i] = INT_MIN;
400 if (
h->default_ref[
list].parent
408 int list2 = (
list+j)&1;
409 if (
h->default_ref[list2].parent && !
h->default_ref[list2].parent->gray
447 "illegal modification_of_pic_nums_idc %u\n",
476 for (
int i = 0;
h->delayed_pic[
i];
i++)
477 if(pic ==
h->delayed_pic[
i]){
495 for (
int 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;
566 for (
int i = 0;
i < 16;
i++)
568 assert(
h->long_ref_count == 0);
570 if (
h->short_ref_count && !
h->last_pic_for_ec.f->data[0]) {
575 for (
int i = 0;
i <
h->short_ref_count;
i++) {
579 h->short_ref_count = 0;
581 memset(
h->default_ref, 0,
sizeof(
h->default_ref));
586 MMCO *mmco =
h->mmco;
589 if (
h->short_ref_count &&
590 h->long_ref_count +
h->short_ref_count >=
h->ps.sps->ref_frame_count &&
593 mmco[0].
short_pic_num =
h->short_ref[
h->short_ref_count - 1]->frame_num;
603 h->nb_mmco = nb_mmco;
608 MMCO *mmco =
h->mmco;
610 int pps_ref_count[2] = {0};
611 int current_ref_assigned = 0, err = 0;
619 if (!
h->explicit_ref_marking)
621 mmco_count =
h->nb_mmco;
626 for (
int i = 0;
i < mmco_count;
i++) {
629 h->mmco[
i].short_pic_num,
h->mmco[
i].long_arg);
631 switch (mmco[
i].opcode) {
641 h->long_ref[mmco[
i].
long_arg]->frame_num != frame_num) {
650 h->mmco[
i].short_pic_num,
h->short_ref_count);
682 if (
h->short_ref[0] ==
h->cur_pic_ptr) {
683 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to short and long at the same time\n");
688 if (
h->cur_pic_ptr->long_ref) {
690 if (
h->long_ref[j] ==
h->cur_pic_ptr) {
691 if (j != mmco[
i].long_arg)
692 av_log(
h->avctx,
AV_LOG_ERROR,
"mmco: cannot assign current picture to 2 long term references\n");
698 if (
h->long_ref[mmco[
i].
long_arg] !=
h->cur_pic_ptr) {
707 h->cur_pic_ptr->reference |=
h->picture_structure;
708 current_ref_assigned = 1;
711 assert(mmco[
i].long_arg <= 16);
713 for (
int j = mmco[
i].long_arg; j < 16; j++)
717 while (
h->short_ref_count) {
720 for (
int j = 0; j < 16; j++)
722 h->poc.frame_num =
h->cur_pic_ptr->frame_num = 0;
724 h->cur_pic_ptr->mmco_reset = 1;
726 h->last_pocs[j] = INT_MIN;
732 if (!current_ref_assigned) {
739 if (
h->short_ref_count &&
h->short_ref[0] ==
h->cur_pic_ptr) {
741 h->cur_pic_ptr->reference |=
h->picture_structure;
742 }
else if (
h->cur_pic_ptr->long_ref) {
744 "assignment for second field "
745 "in complementary field pair "
746 "(first field is long term)\n");
755 if (
h->short_ref_count)
756 memmove(&
h->short_ref[1], &
h->short_ref[0],
759 h->short_ref[0] =
h->cur_pic_ptr;
760 h->short_ref_count++;
761 h->cur_pic_ptr->reference |=
h->picture_structure;
765 if (
h->long_ref_count +
h->short_ref_count >
FFMAX(
h->ps.sps->ref_frame_count, 1)) {
772 "number of reference frames (%d+%d) exceeds max (%d; probably "
773 "corrupt input), discarding one\n",
774 h->long_ref_count,
h->short_ref_count,
h->ps.sps->ref_frame_count);
777 if (
h->long_ref_count && !
h->short_ref_count) {
779 for (
i = 0;
i < 16; ++
i)
791 for (
int i = 0;
i <
h->short_ref_count;
i++) {
795 if (d >
h->ps.sps->ref_frame_count)
804 if (
h->ps.pps_list[
i]) {
806 pps_ref_count[0] =
FFMAX(pps_ref_count[0],
pps->ref_count[0]);
807 pps_ref_count[1] =
FFMAX(pps_ref_count[1],
pps->ref_count[1]);
813 &&
h->long_ref_count==0
814 && (
h->short_ref_count<=2
815 || pps_ref_count[0] <= 2 && pps_ref_count[1] <= 1 &&
h->avctx->has_b_frames
816 || pps_ref_count[0] <= 1 + (
h->picture_structure !=
PICT_FRAME) && pps_ref_count[1] <= 1)
817 && pps_ref_count[0]<=2 + (
h->picture_structure !=
PICT_FRAME) + (2*!
h->has_recovery_point)
820 if(!
h->avctx->has_b_frames)
858 if (long_arg >= 32 ||
863 "illegal long ref in memory management control "
864 "operation %d\n", opcode);
873 "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)
struct H264SliceContext::@125 ref_modifications[2][32]
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)
#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)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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)
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 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)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int long_ref
1->long term reference 0->short term reference