Browse code

avcodec/msvideo1enc: drop dependancy on sizeof(AVFrame)

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

Michael Niedermayer authored on 2013/12/18 00:27:36
Showing 1 changed files
... ...
@@ -35,7 +35,6 @@
35 35
  */
36 36
 typedef struct Msvideo1EncContext {
37 37
     AVCodecContext *avctx;
38
-    AVFrame pic;
39 38
     AVLFG rnd;
40 39
     uint8_t *prev;
41 40
 
... ...
@@ -67,7 +66,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
67 67
                                const AVFrame *pict, int *got_packet)
68 68
 {
69 69
     Msvideo1EncContext * const c = avctx->priv_data;
70
-    AVFrame * const p = &c->pic;
70
+    const AVFrame *p = pict;
71 71
     uint16_t *src;
72 72
     uint8_t *prevptr;
73 73
     uint8_t *dst, *buf;
... ...
@@ -75,12 +74,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
75 75
     int no_skips = 1;
76 76
     int i, j, k, x, y, ret;
77 77
     int skips = 0;
78
+    int quality = 24;
78 79
 
79 80
     if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0)
80 81
         return ret;
81 82
     dst= buf= pkt->data;
82 83
 
83
-    *p = *pict;
84 84
     if(!c->prev)
85 85
         c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
86 86
     prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
... ...
@@ -88,7 +87,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
88 88
     if(c->keyint >= avctx->keyint_min)
89 89
         keyframe = 1;
90 90
 
91
-    p->quality = 24;
92 91
 
93 92
     for(y = 0; y < avctx->height; y += 4){
94 93
         for(x = 0; x < avctx->width; x += 4){
... ...
@@ -114,7 +112,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
114 114
                         bestscore += t*t;
115 115
                     }
116 116
                 }
117
-                bestscore /= p->quality;
117
+                bestscore /= quality;
118 118
             }
119 119
             // try to find optimal value to fill whole 4x4 block
120 120
             score = 0;
... ...
@@ -130,7 +128,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
130 130
                     }
131 131
                 }
132 132
             }
133
-            score /= p->quality;
133
+            score /= quality;
134 134
             score += 2;
135 135
             if(score < bestscore){
136 136
                 bestscore = score;
... ...
@@ -155,7 +153,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
155 155
                     }
156 156
                 }
157 157
             }
158
-            score /= p->quality;
158
+            score /= quality;
159 159
             score += 6;
160 160
             if(score < bestscore){
161 161
                 bestscore = score;
... ...
@@ -182,7 +180,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
182 182
                     }
183 183
                 }
184 184
             }
185
-            score /= p->quality;
185
+            score /= quality;
186 186
             score += 18;
187 187
             if(score < bestscore){
188 188
                 bestscore = score;
... ...
@@ -248,8 +246,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
248 248
         c->keyint = 0;
249 249
     else
250 250
         c->keyint++;
251
-    p->pict_type= keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
252
-    p->key_frame= keyframe;
253 251
     if (keyframe) pkt->flags |= AV_PKT_FLAG_KEY;
254 252
     pkt->size = dst - buf;
255 253
     *got_packet = 1;
... ...
@@ -274,8 +270,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
274 274
         return -1;
275 275
     }
276 276
 
277
-    avcodec_get_frame_defaults(&c->pic);
278
-    avctx->coded_frame = (AVFrame*)&c->pic;
279 277
     avctx->bits_per_coded_sample = 16;
280 278
 
281 279
     c->keyint = avctx->keyint_min;