OSDN Git Service

h261: Move encoder/decoder shared table init to common code
authorDiego Biurrun <diego@biurrun.de>
Fri, 5 Apr 2013 21:43:31 +0000 (23:43 +0200)
committerDiego Biurrun <diego@biurrun.de>
Wed, 10 Apr 2013 11:32:04 +0000 (13:32 +0200)
libavcodec/h261.c
libavcodec/h261.h
libavcodec/h261dec.c
libavcodec/h261enc.c

index f1b8800..b9783f1 100644 (file)
@@ -79,3 +79,14 @@ void ff_h261_loop_filter(MpegEncContext *s)
     h261_loop_filter(dest_cb, uvlinesize);
     h261_loop_filter(dest_cr, uvlinesize);
 }
+
+av_cold void ff_h261_common_init(void)
+{
+    static int done = 0;
+
+    if (done)
+        return;
+
+    ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
+    done = 1;
+}
index a1a0a41..ad7e28b 100644 (file)
@@ -61,6 +61,7 @@ extern const uint8_t ff_h261_cbp_tab[63][2];
 extern RLTable ff_h261_rl_tcoeff;
 
 void ff_h261_loop_filter(MpegEncContext *s);
+void ff_h261_common_init(void);
 
 int ff_h261_get_picture_format(int width, int height);
 void ff_h261_reorder_mb_index(MpegEncContext *s);
index 699f7cf..49756a7 100644 (file)
@@ -61,7 +61,6 @@ static av_cold void h261_decode_init_vlc(H261Context *h)
         INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
                         &ff_h261_cbp_tab[0][1], 2, 1,
                         &ff_h261_cbp_tab[0][0], 2, 1, 512);
-        ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
         INIT_VLC_RL(ff_h261_rl_tcoeff, 552);
     }
 }
@@ -82,6 +81,7 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
     s->codec_id    = avctx->codec->id;
 
+    ff_h261_common_init();
     h261_decode_init_vlc(h);
 
     h->gob_start_code_skipped = 0;
index c866776..3ef7a7c 100644 (file)
@@ -313,12 +313,7 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
 
 void ff_h261_encode_init(MpegEncContext *s)
 {
-    static int done = 0;
-
-    if (!done) {
-        done = 1;
-        ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
-    }
+    ff_h261_common_init();
 
     s->min_qcoeff       = -127;
     s->max_qcoeff       = 127;