mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
Merge commit 'c2597c5a0a08526493abb9bc9544b61a290fe20f'
* commit 'c2597c5a0a08526493abb9bc9544b61a290fe20f': h264_refs: cosmetics, reformat Conflicts: libavcodec/h264_refs.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
87d263a122
@ -53,8 +53,8 @@ static void pic_as_field(Picture *pic, const int parity){
|
||||
pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
|
||||
}
|
||||
|
||||
static int split_field_copy(Picture *dest, Picture *src,
|
||||
int parity, int id_add){
|
||||
static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add)
|
||||
{
|
||||
int match = !!(src->reference & parity);
|
||||
|
||||
if (match) {
|
||||
@ -69,7 +69,8 @@ static int split_field_copy(Picture *dest, Picture *src,
|
||||
return match;
|
||||
}
|
||||
|
||||
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){
|
||||
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)
|
||||
{
|
||||
int i[2] = { 0 };
|
||||
int index = 0;
|
||||
|
||||
@ -91,7 +92,8 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int
|
||||
return index;
|
||||
}
|
||||
|
||||
static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir){
|
||||
static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir)
|
||||
{
|
||||
int i, best_poc;
|
||||
int out_i = 0;
|
||||
|
||||
@ -112,7 +114,8 @@ static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int d
|
||||
return out_i;
|
||||
}
|
||||
|
||||
int ff_h264_fill_default_ref_list(H264Context *h){
|
||||
int ff_h264_fill_default_ref_list(H264Context *h)
|
||||
{
|
||||
int i, len;
|
||||
|
||||
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
|
||||
@ -156,11 +159,17 @@ int ff_h264_fill_default_ref_list(H264Context *h){
|
||||
}
|
||||
#ifdef TRACE
|
||||
for (i = 0; i < h->ref_count[0]; i++) {
|
||||
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].f.data[0]);
|
||||
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
|
||||
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
|
||||
h->default_ref_list[0][i].pic_id,
|
||||
h->default_ref_list[0][i].f.data[0]);
|
||||
}
|
||||
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
|
||||
for (i = 0; i < h->ref_count[1]; i++) {
|
||||
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].f.data[0]);
|
||||
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
|
||||
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
|
||||
h->default_ref_list[1][i].pic_id,
|
||||
h->default_ref_list[1][i].f.data[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -180,7 +189,8 @@ static void print_long_term(H264Context *h);
|
||||
* @return frame number (short term) or long term index of picture
|
||||
* described by pic_num
|
||||
*/
|
||||
static int pic_num_extract(H264Context *h, int pic_num, int *structure){
|
||||
static int pic_num_extract(H264Context *h, int pic_num, int *structure)
|
||||
{
|
||||
*structure = h->picture_structure;
|
||||
if (FIELD_PICTURE) {
|
||||
if (!(pic_num & 1))
|
||||
@ -192,7 +202,8 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure){
|
||||
return pic_num;
|
||||
}
|
||||
|
||||
int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
|
||||
int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
|
||||
{
|
||||
int list, index, pic_structure, i;
|
||||
|
||||
print_short_term(h);
|
||||
@ -229,8 +240,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
|
||||
else pred+= abs_diff_pic_num;
|
||||
if (reordering_of_pic_nums_idc == 0)
|
||||
pred -= abs_diff_pic_num;
|
||||
else
|
||||
pred += abs_diff_pic_num;
|
||||
pred &= h->max_pic_num - 1;
|
||||
|
||||
frame_num = pic_num_extract(h, pred, &pic_structure);
|
||||
@ -239,10 +252,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
|
||||
ref = h->short_ref[i];
|
||||
assert(ref->reference);
|
||||
assert(!ref->long_ref);
|
||||
if(
|
||||
ref->frame_num == frame_num &&
|
||||
(ref->reference & pic_structure)
|
||||
)
|
||||
if (ref->frame_num == frame_num &&
|
||||
(ref->reference & pic_structure))
|
||||
break;
|
||||
}
|
||||
if (i >= 0)
|
||||
@ -273,7 +284,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
|
||||
memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
|
||||
} else {
|
||||
for (i = index; i + 1 < h->ref_count[list]; i++) {
|
||||
if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id)
|
||||
if (ref->long_ref == h->ref_list[list][i].long_ref &&
|
||||
ref->pic_id == h->ref_list[list][i].pic_id)
|
||||
break;
|
||||
}
|
||||
for (; i > index; i--) {
|
||||
@ -311,7 +323,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ff_h264_fill_mbaff_ref_list(H264Context *h){
|
||||
void ff_h264_fill_mbaff_ref_list(H264Context *h)
|
||||
{
|
||||
int list, i, j;
|
||||
for (list = 0; list < h->list_count; list++) {
|
||||
for (i = 0; i < h->ref_count[list]; i++) {
|
||||
@ -349,7 +362,8 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){
|
||||
* for display purposes) zero if one of the fields remains in
|
||||
* reference
|
||||
*/
|
||||
static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){
|
||||
static inline int unreference_pic(H264Context *h, Picture *pic, int refmask)
|
||||
{
|
||||
int i;
|
||||
if (pic->reference &= refmask) {
|
||||
return 0;
|
||||
@ -371,7 +385,8 @@ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){
|
||||
* @return pointer to the found picture, or NULL if no pic with the provided
|
||||
* frame number is found
|
||||
*/
|
||||
static Picture * find_short(H264Context *h, int frame_num, int *idx){
|
||||
static Picture *find_short(H264Context *h, int frame_num, int *idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < h->short_ref_count; i++) {
|
||||
@ -392,18 +407,21 @@ static Picture * find_short(H264Context *h, int frame_num, int *idx){
|
||||
* to be valid. Other list entries are shifted down.
|
||||
* @param i index into h->short_ref of picture to remove.
|
||||
*/
|
||||
static void remove_short_at_index(H264Context *h, int i){
|
||||
static void remove_short_at_index(H264Context *h, int i)
|
||||
{
|
||||
assert(i >= 0 && i < h->short_ref_count);
|
||||
h->short_ref[i] = NULL;
|
||||
if (--h->short_ref_count)
|
||||
memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*));
|
||||
memmove(&h->short_ref[i], &h->short_ref[i + 1],
|
||||
(h->short_ref_count - i) * sizeof(Picture*));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the removed picture or NULL if an error occurs
|
||||
*/
|
||||
static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){
|
||||
static Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
|
||||
{
|
||||
Picture *pic;
|
||||
int i;
|
||||
|
||||
@ -424,7 +442,8 @@ static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){
|
||||
* that list.
|
||||
* @return the removed picture or NULL if an error occurs
|
||||
*/
|
||||
static Picture * remove_long(H264Context *h, int i, int ref_mask){
|
||||
static Picture *remove_long(H264Context *h, int i, int ref_mask)
|
||||
{
|
||||
Picture *pic;
|
||||
|
||||
pic = h->long_ref[i];
|
||||
@ -440,7 +459,8 @@ static Picture * remove_long(H264Context *h, int i, int ref_mask){
|
||||
return pic;
|
||||
}
|
||||
|
||||
void ff_h264_remove_all_refs(H264Context *h){
|
||||
void ff_h264_remove_all_refs(H264Context *h)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
@ -461,7 +481,8 @@ void ff_h264_remove_all_refs(H264Context *h){
|
||||
/**
|
||||
* print short term list
|
||||
*/
|
||||
static void print_short_term(H264Context *h) {
|
||||
static void print_short_term(H264Context *h)
|
||||
{
|
||||
uint32_t i;
|
||||
if (h->avctx->debug & FF_DEBUG_MMCO) {
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n");
|
||||
@ -476,7 +497,8 @@ static void print_short_term(H264Context *h) {
|
||||
/**
|
||||
* print long term list
|
||||
*/
|
||||
static void print_long_term(H264Context *h) {
|
||||
static void print_long_term(H264Context *h)
|
||||
{
|
||||
uint32_t i;
|
||||
if (h->avctx->debug & FF_DEBUG_MMCO) {
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n");
|
||||
@ -537,7 +559,8 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
||||
{
|
||||
int i, av_uninit(j);
|
||||
int current_ref_assigned = 0, err = 0;
|
||||
Picture *av_uninit(pic);
|
||||
@ -548,15 +571,17 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
for (i = 0; i < mmco_count; i++) {
|
||||
int av_uninit(structure), av_uninit(frame_num);
|
||||
if (h->avctx->debug & FF_DEBUG_MMCO)
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
|
||||
h->mmco[i].short_pic_num, h->mmco[i].long_arg);
|
||||
|
||||
if( mmco[i].opcode == MMCO_SHORT2UNUSED
|
||||
|| mmco[i].opcode == MMCO_SHORT2LONG){
|
||||
if (mmco[i].opcode == MMCO_SHORT2UNUSED ||
|
||||
mmco[i].opcode == MMCO_SHORT2LONG) {
|
||||
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
|
||||
pic = find_short(h, frame_num, &j);
|
||||
if (!pic) {
|
||||
if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
|
||||
|| h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
||||
if (mmco[i].opcode != MMCO_SHORT2LONG ||
|
||||
!h->long_ref[mmco[i].long_arg] ||
|
||||
h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
|
||||
err = AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -567,7 +592,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
switch (mmco[i].opcode) {
|
||||
case MMCO_SHORT2UNUSED:
|
||||
if (h->avctx->debug & FF_DEBUG_MMCO)
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
|
||||
h->mmco[i].short_pic_num, h->short_ref_count);
|
||||
remove_short(h, frame_num, structure ^ PICT_FRAME);
|
||||
break;
|
||||
case MMCO_SHORT2LONG:
|
||||
@ -623,8 +649,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
for (j = 0; j < 16; j++) {
|
||||
remove_long(h, j, 0);
|
||||
}
|
||||
h->frame_num=
|
||||
h->cur_pic_ptr->frame_num= 0;
|
||||
h->frame_num = h->cur_pic_ptr->frame_num = 0;
|
||||
h->mmco_reset = 1;
|
||||
h->cur_pic_ptr->mmco_reset = 1;
|
||||
for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
|
||||
@ -658,7 +683,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
}
|
||||
|
||||
if (h->short_ref_count)
|
||||
memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
|
||||
memmove(&h->short_ref[1], &h->short_ref[0],
|
||||
h->short_ref_count * sizeof(Picture*));
|
||||
|
||||
h->short_ref[0] = h->cur_pic_ptr;
|
||||
h->short_ref_count++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user