Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-22 00:08:19 +0300
committerMichael Niedermayer <michaelni@gmx.at>2015-03-22 01:05:34 +0300
commitd8151a7e944aea52d167571badc247c8d9972847 (patch)
tree00f3d6dcaf271371dc5a2ef284baefb8697d446d /libavcodec/h264_refs.c
parente970b576d28dd515d4ccd665b53763e228816cac (diff)
parenta12d3188cbec15e22070e139fa5cc541da07e2c3 (diff)
Merge commit 'a12d3188cbec15e22070e139fa5cc541da07e2c3'
* commit 'a12d3188cbec15e22070e139fa5cc541da07e2c3': h264: use a smaller struct for the ref lists Conflicts: libavcodec/h264_direct.c libavcodec/h264_mb.c libavcodec/h264_picture.c libavcodec/h264_refs.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h264_refs.c')
-rw-r--r--libavcodec/h264_refs.c83
1 files changed, 47 insertions, 36 deletions
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 6c7ec60e68..6d72d2ae19 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -36,24 +36,34 @@
#include <assert.h>
-
-static void pic_as_field(H264Picture *pic, const int parity){
+static void pic_as_field(H264Ref *pic, const int parity)
+{
int i;
- for (i = 0; i < 4; ++i) {
+ for (i = 0; i < FF_ARRAY_ELEMS(pic->data); ++i) {
if (parity == PICT_BOTTOM_FIELD)
- pic->f.data[i] += pic->f.linesize[i];
+ pic->data[i] += pic->linesize[i];
pic->reference = parity;
- pic->f.linesize[i] *= 2;
+ pic->linesize[i] *= 2;
}
- pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
+ pic->poc = pic->parent->field_poc[parity == PICT_BOTTOM_FIELD];
+}
+
+static void ref_from_h264pic(H264Ref *dst, H264Picture *src)
+{
+ memcpy(dst->data, src->f.data, sizeof(dst->data));
+ memcpy(dst->linesize, src->f.linesize, sizeof(dst->linesize));
+ dst->reference = src->reference;
+ dst->poc = src->poc;
+ dst->pic_id = src->pic_id;
+ dst->parent = src;
}
-static int split_field_copy(H264Picture *dest, H264Picture *src, int parity, int id_add)
+static int split_field_copy(H264Ref *dest, H264Picture *src, int parity, int id_add)
{
int match = !!(src->reference & parity);
if (match) {
- COPY_PICTURE(dest, src);
+ ref_from_h264pic(dest, src);
if (parity != PICT_FRAME) {
pic_as_field(dest, parity);
dest->pic_id *= 2;
@@ -64,7 +74,7 @@ static int split_field_copy(H264Picture *dest, H264Picture *src, int parity, int
return match;
}
-static int build_def_list(H264Picture *def, int def_len,
+static int build_def_list(H264Ref *def, int def_len,
H264Picture **in, int len, int is_long, int sel)
{
int i[2] = { 0 };
@@ -139,19 +149,16 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
av_assert0(len <= 32);
if (len < sl->ref_count[list])
- memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (sl->ref_count[list] - len));
+ memset(&h->default_ref_list[list][len], 0, sizeof(H264Ref) * (sl->ref_count[list] - len));
lens[list] = len;
}
if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; i < lens[0] &&
- h->default_ref_list[0][i].f.buf[0]->buffer ==
- h->default_ref_list[1][i].f.buf[0]->buffer; i++);
+ h->default_ref_list[0][i].parent->f.buf[0]->buffer ==
+ h->default_ref_list[1][i].parent->f.buf[0]->buffer; i++);
if (i == lens[0]) {
- H264Picture tmp;
- COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
- COPY_PICTURE(&h->default_ref_list[1][0], &h->default_ref_list[1][1]);
- COPY_PICTURE(&h->default_ref_list[1][1], &tmp);
+ FFSWAP(H264Ref, h->default_ref_list[1][0], h->default_ref_list[1][1]);
}
}
} else {
@@ -163,7 +170,7 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
av_assert0(len <= 32);
if (len < sl->ref_count[0])
- memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (sl->ref_count[0] - len));
+ memset(&h->default_ref_list[0][len], 0, sizeof(H264Ref) * (sl->ref_count[0] - len));
}
#ifdef TRACE
for (i = 0; i < sl->ref_count[0]; i++) {
@@ -212,14 +219,13 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure)
int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{
- int list, index, pic_structure, i;
+ int list, index, pic_structure;
print_short_term(h);
print_long_term(h);
for (list = 0; list < sl->list_count; list++) {
- for (i = 0; i < sl->ref_count[list]; i++)
- COPY_PICTURE(&sl->ref_list[list][i], &h->default_ref_list[list][i]);
+ memcpy(sl->ref_list[list], h->default_ref_list[list], sl->ref_count[list] * sizeof(sl->ref_list[0][0]));
if (get_bits1(&sl->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num;
@@ -302,17 +308,18 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n");
- memset(&sl->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME
+ memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0])); // FIXME
} else {
for (i = index; i + 1 < sl->ref_count[list]; i++) {
- if (ref->long_ref == sl->ref_list[list][i].long_ref &&
+ if (sl->ref_list[list][i].parent &&
+ ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
- COPY_PICTURE(&sl->ref_list[list][i], &sl->ref_list[list][i - 1]);
+ sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
- COPY_PICTURE(&sl->ref_list[list][index], ref);
+ ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
}
@@ -322,19 +329,19 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
}
for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < sl->ref_count[list]; index++) {
- if ( !sl->ref_list[list][index].f.buf[0]
+ if ( !sl->ref_list[list][index].parent
|| (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
- if (h->default_ref_list[list][0].f.buf[0]
+ if (h->default_ref_list[list][0].parent
&& !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3))
- COPY_PICTURE(&sl->ref_list[list][index], &h->default_ref_list[list][0]);
+ sl->ref_list[list][index] = h->default_ref_list[list][0];
else
return -1;
}
- av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].f.buf[0]) > 0);
+ av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f.buf[0]) > 0);
}
}
@@ -346,18 +353,22 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl)
int list, i, j;
for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < sl->ref_count[list]; i++) {
- H264Picture *frame = &sl->ref_list[list][i];
- H264Picture *field = &sl->ref_list[list][16 + 2 * i];
- COPY_PICTURE(field, frame);
+ H264Ref *frame = &sl->ref_list[list][i];
+ H264Ref *field = &sl->ref_list[list][16 + 2 * i];
+
+ field[0] = *frame;
+
for (j = 0; j < 3; j++)
- field[0].f.linesize[j] <<= 1;
+ field[0].linesize[j] <<= 1;
field[0].reference = PICT_TOP_FIELD;
- field[0].poc = field[0].field_poc[0];
- COPY_PICTURE(field + 1, field);
+ field[0].poc = field[0].parent->field_poc[0];
+
+ field[1] = field[0];
+
for (j = 0; j < 3; j++)
- field[1].f.data[j] += frame->f.linesize[j];
+ field[1].data[j] += frame->parent->f.linesize[j];
field[1].reference = PICT_BOTTOM_FIELD;
- field[1].poc = field[1].field_poc[1];
+ field[1].poc = field[1].parent->field_poc[1];
sl->luma_weight[16 + 2 * i][list][0] = sl->luma_weight[16 + 2 * i + 1][list][0] = sl->luma_weight[i][list][0];
sl->luma_weight[16 + 2 * i][list][1] = sl->luma_weight[16 + 2 * i + 1][list][1] = sl->luma_weight[i][list][1];