Browse code

Add possibility to crop screens inside of encoded frames.

Originally committed as revision 25346 to svn://svn.ffmpeg.org/ffmpeg/trunk

Tobias Bindhammer authored on 2010/10/05 21:14:23
Showing 1 changed files
... ...
@@ -33,6 +33,7 @@
33 33
 #define DITHERSTEPS   8
34 34
 #define CHARSET_CHARS 256
35 35
 #define INTERLACED    1
36
+#define CROP_SCREENS  1
36 37
 
37 38
 /* gray gradient */
38 39
 static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
... ...
@@ -245,7 +246,9 @@ static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf,
245 245
     AVFrame *const p = (AVFrame *) & c->picture;
246 246
 
247 247
     int frame;
248
-    int a;
248
+    int x, y;
249
+    int b_height;
250
+    int b_width;
249 251
 
250 252
     int req_size;
251 253
     int num_frames = c->mc_lifetime;
... ...
@@ -257,9 +260,19 @@ static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf,
257 257
     int *best_cb         = c->mc_best_cb;
258 258
 
259 259
     int charset_size = 0x800 * (INTERLACED + 1);
260
-    int screen_size  = 0x400;
260
+    int screen_size;
261 261
     int colram_size  = 0x100 * c->mc_use_5col;
262 262
 
263
+    if(CROP_SCREENS) {
264
+        b_height = FFMIN(avctx->height,C64YRES) >> 3;
265
+        b_width  = FFMIN(avctx->width ,C64XRES) >> 3;
266
+        screen_size = b_width * b_height;
267
+    } else {
268
+        b_height = C64YRES >> 3;
269
+        b_width  = C64XRES >> 3;
270
+        screen_size = 0x400;
271
+    }
272
+
263 273
     /* no data, means end encoding asap */
264 274
     if (!data) {
265 275
         /* all done, end encoding */
... ...
@@ -312,8 +325,10 @@ static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf,
312 312
         /* write x frames to buf */
313 313
         for (frame = 0; frame < c->mc_lifetime; frame++) {
314 314
             /* copy charmap to buf. buf is uchar*, charmap is int*, so no memcpy here, sorry */
315
-            for (a = 0; a < 1000; a++) {
316
-                buf[a] = charmap[a];
315
+            for (y = 0; y < b_height; y++) {
316
+                for (x = 0; x < b_width; x++) {
317
+                    buf[y * b_width + x] = charmap[y * b_width + x];
318
+                }
317 319
             }
318 320
             /* advance pointers */
319 321
             buf += screen_size;