]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_refs.c
h264: move macroblock decoding into its own file
[ffmpeg] / libavcodec / h264_refs.c
index ccdb49bc5b6bf737765d5620cbce2bcfbc687b79..332866a2db890ea98d5b83a215080353576e2237 100644 (file)
@@ -29,6 +29,7 @@
 #include "avcodec.h"
 #include "h264.h"
 #include "golomb.h"
+#include "mpegutils.h"
 
 #include <assert.h>
 
@@ -40,7 +41,7 @@ do {\
 } while (0)
 
 
-static void pic_as_field(Picture *pic, const int parity){
+static void pic_as_field(H264Picture *pic, const int parity){
     int i;
     for (i = 0; i < 4; ++i) {
         if (parity == PICT_BOTTOM_FIELD)
@@ -51,7 +52,7 @@ 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(H264Picture *dest, H264Picture *src, int parity, int id_add)
 {
     int match = !!(src->reference & parity);
 
@@ -67,8 +68,8 @@ static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add)
     return match;
 }
 
-static int build_def_list(Picture *def, int def_len,
-                          Picture **in, int len, int is_long, int sel)
+static int build_def_list(H264Picture *def, int def_len,
+                          H264Picture **in, int len, int is_long, int sel)
 {
     int  i[2] = { 0 };
     int index = 0;
@@ -91,7 +92,7 @@ static int build_def_list(Picture *def, int def_len,
     return index;
 }
 
-static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir)
+static int add_sorted(H264Picture **sorted, H264Picture **src, int len, int limit, int dir)
 {
     int i, best_poc;
     int out_i = 0;
@@ -118,7 +119,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
     int i, len;
 
     if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
-        Picture *sorted[32];
+        H264Picture *sorted[32];
         int cur_poc, list;
         int lens[2];
 
@@ -139,7 +140,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
                                   h->long_ref, 16, 1, h->picture_structure);
 
             if (len < h->ref_count[list])
-                memset(&h->default_ref_list[list][len], 0, sizeof(Picture) * (h->ref_count[list] - len));
+                memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (h->ref_count[list] - len));
             lens[list] = len;
         }
 
@@ -148,7 +149,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
                         h->default_ref_list[0][i].f.buf[0]->buffer ==
                         h->default_ref_list[1][i].f.buf[0]->buffer; i++);
             if (i == lens[0]) {
-                Picture tmp;
+                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);
@@ -162,7 +163,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
                               h-> long_ref, 16, 1, h->picture_structure);
 
         if (len < h->ref_count[0])
-            memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
+            memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (h->ref_count[0] - len));
     }
 #ifdef TRACE
     for (i = 0; i < h->ref_count[0]; i++) {
@@ -227,7 +228,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                 unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
                 unsigned int pic_id;
                 int i;
-                Picture *ref = NULL;
+                H264Picture *ref = NULL;
 
                 if (modification_of_pic_nums_idc == 3)
                     break;
@@ -301,7 +302,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                 if (i < 0) {
                     av_log(h->avctx, AV_LOG_ERROR,
                            "reference picture missing during reorder\n");
-                    memset(&h->ref_list[list][index], 0, sizeof(Picture)); // FIXME
+                    memset(&h->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME
                 } else {
                     for (i = index; i + 1 < h->ref_count[list]; i++) {
                         if (ref->long_ref == h->ref_list[list][i].long_ref &&
@@ -339,8 +340,8 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h)
     int list, i, j;
     for (list = 0; list < 2; list++) { //FIXME try list_count
         for (i = 0; i < h->ref_count[list]; i++) {
-            Picture *frame = &h->ref_list[list][i];
-            Picture *field = &h->ref_list[list][16 + 2 * i];
+            H264Picture *frame = &h->ref_list[list][i];
+            H264Picture *field = &h->ref_list[list][16 + 2 * i];
             COPY_PICTURE(field, frame);
             for (j = 0; j < 3; j++)
                 field[0].f.linesize[j] <<= 1;
@@ -373,7 +374,7 @@ 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, H264Picture *pic, int refmask)
 {
     int i;
     if (pic->reference &= refmask) {
@@ -389,19 +390,19 @@ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask)
 }
 
 /**
- * Find a Picture in the short term reference list by frame number.
+ * Find a H264Picture in the short term reference list by frame number.
  * @param frame_num frame number to search for
  * @param idx the index into h->short_ref where returned picture is found
  *            undefined if no picture found.
  * @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 H264Picture *find_short(H264Context *h, int frame_num, int *idx)
 {
     int i;
 
     for (i = 0; i < h->short_ref_count; i++) {
-        Picture *pic = h->short_ref[i];
+        H264Picture *pic = h->short_ref[i];
         if (h->avctx->debug & FF_DEBUG_MMCO)
             av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
         if (pic->frame_num == frame_num) {
@@ -424,16 +425,16 @@ static void remove_short_at_index(H264Context *h, int i)
     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*));
+                (h->short_ref_count - i) * sizeof(H264Picture*));
 }
 
 /**
  *
  * @return the removed picture or NULL if an error occurs
  */
-static Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
+static H264Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
 {
-    Picture *pic;
+    H264Picture *pic;
     int i;
 
     if (h->avctx->debug & FF_DEBUG_MMCO)
@@ -453,9 +454,9 @@ 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 H264Picture *remove_long(H264Context *h, int i, int ref_mask)
 {
-    Picture *pic;
+    H264Picture *pic;
 
     pic = h->long_ref[i];
     if (pic) {
@@ -495,7 +496,7 @@ static void print_short_term(H264Context *h)
     if (h->avctx->debug & FF_DEBUG_MMCO) {
         av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n");
         for (i = 0; i < h->short_ref_count; i++) {
-            Picture *pic = h->short_ref[i];
+            H264Picture *pic = h->short_ref[i];
             av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
                    i, pic->frame_num, pic->poc, pic->f.data[0]);
         }
@@ -511,7 +512,7 @@ static void print_long_term(H264Context *h)
     if (h->avctx->debug & FF_DEBUG_MMCO) {
         av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n");
         for (i = 0; i < 16; i++) {
-            Picture *pic = h->long_ref[i];
+            H264Picture *pic = h->long_ref[i];
             if (pic) {
                 av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
                        i, pic->frame_num, pic->poc, pic->f.data[0]);
@@ -570,7 +571,7 @@ 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);
+    H264Picture *av_uninit(pic);
 
     if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0)
         av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
@@ -691,7 +692,7 @@ 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*));
+                        h->short_ref_count * sizeof(H264Picture*));
 
             h->short_ref[0] = h->cur_pic_ptr;
             h->short_ref_count++;