[FFmpeg-cvslog] dvenc: initialize the profile only once, at init

Anton Khirnov git at videolan.org
Fri Jun 20 17:58:45 CEST 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jun 18 10:39:13 2014 +0200| [778111592bf5f38630858ee6dfcfd097cd6c6da9] | committer: Anton Khirnov

dvenc: initialize the profile only once, at init

We do not allow the frame parameters to change during encoding, so there
is no need to do this for each frame.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=778111592bf5f38630858ee6dfcfd097cd6c6da9
---

 libavcodec/dvenc.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 6338dee..552f691 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -35,13 +35,22 @@
 
 static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
-    if (!avpriv_dv_codec_profile(avctx)) {
+    DVVideoContext *s = avctx->priv_data;
+    int ret;
+
+    s->sys = avpriv_dv_codec_profile(avctx);
+    if (!s->sys) {
         av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
                "Valid DV profiles are:\n",
                avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt));
         ff_dv_print_profiles(avctx, AV_LOG_ERROR);
         return AVERROR(EINVAL);
     }
+    ret = ff_dv_init_dynamic_tables(s->sys);
+    if (ret < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n");
+        return ret;
+    }
 
     avctx->coded_frame = av_frame_alloc();
     if (!avctx->coded_frame)
@@ -660,9 +669,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
     DVVideoContext *s = c->priv_data;
     int ret;
 
-    s->sys = avpriv_dv_codec_profile(c);
-    if (!s->sys || ff_dv_init_dynamic_tables(s->sys))
-        return -1;
     if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {
         av_log(c, AV_LOG_ERROR, "Error getting output packet.\n");
         return ret;



More information about the ffmpeg-cvslog mailing list