[FFmpeg-cvslog] avcodec/mjpegenc: drop dependancy on sizeof(AVFrame)

Michael Niedermayer git at videolan.org
Tue Dec 17 16:54:28 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Dec 17 16:27:36 2013 +0100| [5b3f4b3ef590b1221d44d24345a846c1aa636b69] | committer: Michael Niedermayer

avcodec/mjpegenc: drop dependancy on sizeof(AVFrame)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/mjpegenc.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index ffc29fd..f23343a 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -537,8 +537,8 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
 
 {
     MpegEncContext *s = avctx->priv_data;
-    AVFrame pic = *pic_arg;
-    int i;
+    AVFrame *pic;
+    int i, ret;
     int chroma_h_shift, chroma_v_shift;
 
     av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
@@ -547,13 +547,17 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
     if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
         return -1;
 
+    pic = av_frame_alloc();
+    av_frame_ref(pic, pic_arg);
     //picture should be flipped upside-down
     for(i=0; i < 3; i++) {
         int vsample = i ? 2 >> chroma_v_shift : 2;
-        pic.data[i] += (pic.linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
-        pic.linesize[i] *= -1;
+        pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
+        pic->linesize[i] *= -1;
     }
-    return ff_MPV_encode_picture(avctx, pkt, &pic, got_packet);
+    ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);
+    av_frame_free(&pic);
+    return ret;
 }
 
 #if CONFIG_MJPEG_ENCODER



More information about the ffmpeg-cvslog mailing list