disabled aspect code due to it is extra buggy
authorAlex Beregszaszi <alex@rtfs.hu>
Sun, 22 Dec 2002 22:34:42 +0000 (22:34 +0000)
committerAlex Beregszaszi <alex@rtfs.hu>
Sun, 22 Dec 2002 22:34:42 +0000 (22:34 +0000)
Originally committed as revision 1359 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/mjpeg.c

index 2e6dd8f..47ace7b 100644 (file)
@@ -720,6 +720,8 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
     s->buffer_size = 102400; /* smaller buffer should be enough,
                                but photojpg files could ahive bigger sizes */
     s->buffer = av_malloc(s->buffer_size);
+    if (!s->buffer)
+       return -1;
     s->start_code = -1;
     s->first_picture = 1;
     s->org_width = avctx->width;
@@ -1183,17 +1185,24 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
            int x_density = get_bits(&s->gb, 16);
            int y_density = get_bits(&s->gb, 16);
 
+           dprintf("x/y density: %d (%f), %d (%f)\n", x_density,
+               (float)x_density, y_density, (float)y_density);
+#if 0
             //MN: needs to be checked
             if(x_density)
-                s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density);
+//                s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density);
+               s->avctx->aspect_ratio = (float)x_density/y_density;
+               /* it's better, but every JFIF I have seen stores 1:1 */
             else
                 s->avctx->aspect_ratio= 0.0;
+#endif
        }
        else
        {
            skip_bits(&s->gb, 16);
            skip_bits(&s->gb, 16);
        }
+
        t_w = get_bits(&s->gb, 8);
        t_h = get_bits(&s->gb, 8);
        if (t_w && t_h)
@@ -1434,7 +1443,6 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
                case EOI:
 eoi_parser:
                    {
-                        int l;
                         if (s->interlaced) {
                             s->bottom_field ^= 1;
                             /* if not bottom field, do not output image yet */
@@ -1443,15 +1451,8 @@ eoi_parser:
                         }
                         for(i=0;i<3;i++) {
                             picture->data[i] = s->current_picture[i];
-#if 1
-                            l = s->linesize[i];
-                            if (s->interlaced)
-                                l >>= 1;
-                            picture->linesize[i] = l;
-#else
                            picture->linesize[i] = (s->interlaced) ?
                                s->linesize[i] >> 1 : s->linesize[i];
-#endif
                         }
                         *data_size = sizeof(AVPicture);
                         avctx->height = s->height;