[FFmpeg-devel] [PATCH 1/3] h264: make it possible to compile without error_resilience.

Ronald S. Bultje rsbultje at gmail.com
Tue Feb 19 18:04:48 CET 2013


From: "Ronald S. Bultje" <rsbultje at gmail.com>

---
 configure         |  6 +++---
 libavcodec/h264.c | 26 ++++++++++++++++++++++++++
 libavcodec/h264.h |  4 +++-
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 1773d68..670ab35 100755
--- a/configure
+++ b/configure
@@ -1638,7 +1638,7 @@ mdct_select="fft"
 rdft_select="fft"
 mpegaudio_select="mpegaudiodsp"
 mpegaudiodsp_select="dct"
-mpegvideo_select="videodsp"
+mpegvideo_select="error_resilience videodsp"
 mpegvideoenc_select="mpegvideo"
 
 # decoders / encoders
@@ -1689,7 +1689,7 @@ h263_decoder_select="error_resilience h263_parser mpegvideo"
 h263_encoder_select="aandcttables error_resilience mpegvideoenc"
 h263i_decoder_select="h263_decoder"
 h263p_encoder_select="h263_encoder"
-h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
+h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
 huffyuv_encoder_select="huffman"
 iac_decoder_select="fft mdct sinewin"
 imc_decoder_select="fft mdct sinewin"
@@ -1832,7 +1832,7 @@ wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # parsers
-h264_parser_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
+h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
 mpeg4video_parser_select="error_resilience mpegvideo"
 mpegvideo_parser_select="error_resilience mpegvideo"
 vc1_parser_select="error_resilience mpegvideo"
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 79aa283..3c5ecee 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -108,6 +108,7 @@ int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
     return h ? h->sps.num_reorder_frames : 0;
 }
 
+#if CONFIG_ERROR_RESILIENCE
 static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
                               int (*mv)[2][4][2],
                               int mb_x, int mb_y, int mb_intra, int mb_skipped)
@@ -142,6 +143,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
     h->mb_field_decoding_flag = 0;
     ff_h264_hl_decode_mb(h);
 }
+#endif
 
 void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
 {
@@ -1025,11 +1027,13 @@ static void free_tables(H264Context *h, int free_rbsp)
         av_freep(&hx->edge_emu_buffer);
         av_freep(&hx->dc_val_base);
         av_freep(&hx->me.scratchpad);
+#if CONFIG_ERROR_RESILIENCE
         av_freep(&hx->er.mb_index2xy);
         av_freep(&hx->er.error_status_table);
         av_freep(&hx->er.er_temp_buffer);
         av_freep(&hx->er.mbintra_table);
         av_freep(&hx->er.mbskip_table);
+#endif
 
         if (free_rbsp) {
             av_freep(&hx->rbsp_buffer[1]);
@@ -1206,12 +1210,14 @@ static void clone_tables(H264Context *dst, H264Context *src, int i)
  */
 static int context_init(H264Context *h)
 {
+#if CONFIG_ERROR_RESILIENCE
     ERContext *er = &h->er;
     int mb_array_size = h->mb_height * h->mb_stride;
     int y_size  = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
     int c_size  = h->mb_stride * (h->mb_height + 1);
     int yc_size = y_size + 2   * c_size;
     int x, y, i;
+#endif
 
     FF_ALLOCZ_OR_GOTO(h->avctx, h->top_borders[0],
                       h->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
@@ -1225,6 +1231,7 @@ static int context_init(H264Context *h)
     h->ref_cache[1][scan8[7]  + 1] =
     h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
 
+#if CONFIG_ERROR_RESILIENCE
     /* init ER */
     er->avctx          = h->avctx;
     er->dsp            = &h->dsp;
@@ -1264,6 +1271,7 @@ static int context_init(H264Context *h)
     er->dc_val[2] = er->dc_val[1] + c_size;
     for (i = 0; i < yc_size; i++)
         h->dc_val_base[i] = 1024;
+#endif
 
     return 0;
 
@@ -1294,9 +1302,11 @@ static av_cold void common_init(H264Context *h)
 
     h->dequant_coeff_pps = -1;
 
+#if CONFIG_ERROR_RESILIENCE
     h->dsp.dct_bits = 16;
     /* needed so that IDCT permutation is known early */
     ff_dsputil_init(&h->dsp, h->avctx);
+#endif
     ff_videodsp_init(&h->vdsp, 8);
 
     memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
@@ -1553,7 +1563,9 @@ static int decode_update_thread_context(AVCodecContext *dst,
         memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
         memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
 
+#if CONFIG_ERROR_RESILIENCE
         memset(&h->er, 0, sizeof(h->er));
+#endif
         memset(&h->me, 0, sizeof(h->me));
         h->avctx = dst;
         h->DPB   = NULL;
@@ -1729,7 +1741,9 @@ int ff_h264_frame_start(H264Context *h)
     h->cur_pic     = *h->cur_pic_ptr;
     h->cur_pic.f.extended_data = h->cur_pic.f.data;
 
+#if CONFIG_ERROR_RESILIENCE
     ff_er_frame_start(&h->er);
+#endif
 
     assert(h->linesize && h->uvlinesize);
 
@@ -2748,12 +2762,14 @@ static int field_end(H264Context *h, int in_setup)
      * past end by one (callers fault) and resync_mb_y != 0
      * causes problems for the first MB line, too.
      */
+#if CONFIG_ERROR_RESILIENCE
     if (!FIELD_PICTURE && h->current_slice && !h->sps.new) {
         h->er.cur_pic  = h->cur_pic_ptr;
         h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL;
         h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL;
         ff_er_frame_end(&h->er);
     }
+#endif
     emms_c();
 
     h->current_slice = 0;
@@ -2853,8 +2869,10 @@ static int h264_set_parameter_from_sps(H264Context *h)
             ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
             ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
                               h->sps.chroma_format_idc);
+#if CONFIG_ERROR_RESILIENCE
             h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
             ff_dsputil_init(&h->dsp, h->avctx);
+#endif
             ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
         } else {
             av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
@@ -3016,7 +3034,9 @@ static int h264_slice_header_init(H264Context *h, int reinit)
             H264Context *c;
             c = h->thread_context[i] = av_mallocz(sizeof(H264Context));
             c->avctx       = h->avctx;
+#if CONFIG_ERROR_RESILIENCE
             c->dsp         = h->dsp;
+#endif
             c->vdsp        = h->vdsp;
             c->h264dsp     = h->h264dsp;
             c->h264qpel    = h->h264qpel;
@@ -4108,10 +4128,12 @@ static void decode_finish_row(H264Context *h)
 static void er_add_slice(H264Context *h, int startx, int starty,
                          int endx, int endy, int status)
 {
+#if CONFIG_ERROR_RESILIENCE
     ERContext *er = &h->er;
 
     er->ref_count = h->ref_count[0];
     ff_er_add_slice(er, startx, starty, endx, endy, status);
+#endif
 }
 
 static int decode_slice(struct AVCodecContext *avctx, void *arg)
@@ -4300,7 +4322,9 @@ static int execute_decode_slices(H264Context *h, int context_count)
         av_assert0(context_count > 0);
         for (i = 1; i < context_count; i++) {
             hx                    = h->thread_context[i];
+#if CONFIG_ERROR_RESILIENCE
             hx->er.error_count  = 0;
+#endif
             hx->x264_build        = h->x264_build;
         }
 
@@ -4313,8 +4337,10 @@ static int execute_decode_slices(H264Context *h, int context_count)
         h->mb_y              = hx->mb_y;
         h->droppable         = hx->droppable;
         h->picture_structure = hx->picture_structure;
+#if CONFIG_ERROR_RESILIENCE
         for (i = 1; i < context_count; i++)
             h->er.error_count += h->thread_context[i]->er.error_count;
+#endif
     }
 
     return 0;
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index cb69361..6b68988 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -256,7 +256,6 @@ typedef struct MMCO {
  */
 typedef struct H264Context {
     AVCodecContext *avctx;
-    DSPContext       dsp;
     VideoDSPContext vdsp;
     H264DSPContext h264dsp;
     H264ChromaContext h264chroma;
@@ -264,7 +263,10 @@ typedef struct H264Context {
     MotionEstContext me;
     ParseContext parse_context;
     GetBitContext gb;
+#if CONFIG_ERROR_RESILIENCE
+    DSPContext       dsp;
     ERContext er;
+#endif
 
     Picture *DPB;
     Picture *cur_pic_ptr;
-- 
1.8.0



More information about the ffmpeg-devel mailing list