[FFmpeg-trac] #899(undetermined:new): sgi: old regression

FFmpeg trac at avcodec.org
Sun Jan 8 05:07:21 CET 2012


#899: sgi: old regression
-------------------------------------+-------------------------------------
             Reporter:  ami_stuff    |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 this patch introduced white line at the right side in the output:

 {{{
 Date: Sat Sep 19 13:42:41 2009
 New Revision: 19926

 Log:
 Support uncompressed 16 bit sgi image format, as e.g. used by the files at
 http://media.xiph.org/svt/2160p50_CgrLevels_Master_SVTdec05_/1_CrowdRun_2160p50_CgrLevels_MASTER_SVTdec05_/

 Modified:
    trunk/libavcodec/sgidec.c

 Modified: trunk/libavcodec/sgidec.c
 ==============================================================================
 --- trunk/libavcodec/sgidec.c   Sat Sep 19 13:36:51 2009        (r19925)
 +++ trunk/libavcodec/sgidec.c   Sat Sep 19 13:42:41 2009        (r19926)
 @@ -28,6 +28,7 @@ typedef struct SgiState {
      unsigned int width;
      unsigned int height;
      unsigned int depth;
 +    unsigned int bytes_per_channel;
      int linesize;
  } SgiState;

 @@ -125,7 +126,7 @@ static int read_uncompressed_sgi(unsigne
  {
      int x, y, z;
      const uint8_t *ptr;
 -    unsigned int offset = s->height * s->width;
 +    unsigned int offset = s->height * s->width * s->bytes_per_channel;

      /* Test buffer size. */
      if (offset * s->depth > in_end - in_buf) {
 @@ -135,9 +136,10 @@ static int read_uncompressed_sgi(unsigne
      for (y = s->height - 1; y >= 0; y--) {
          out_end = out_buf + (y * s->linesize);
          for (x = s->width; x > 0; x--) {
 -            ptr = in_buf++;
 +            ptr = in_buf += s->bytes_per_channel;
              for(z = 0; z < s->depth; z ++) {
 -                bytestream_put_byte(&out_end, *ptr);
 +                memcpy(out_end, ptr, s->bytes_per_channel);
 +                out_end += s->bytes_per_channel;
                  ptr += offset;
              }
          }
 @@ -155,7 +157,7 @@ static int decode_frame(AVCodecContext *
      AVFrame *picture = data;
      AVFrame *p = &s->picture;
      const uint8_t *in_end = in_buf + buf_size;
 -    unsigned int dimension, bytes_per_channel, rle;
 +    unsigned int dimension, rle;
      int ret = 0;
      uint8_t *out_buf, *out_end;

 @@ -171,13 +173,13 @@ static int decode_frame(AVCodecContext *
      }

      rle = bytestream_get_byte(&in_buf);
 -    bytes_per_channel = bytestream_get_byte(&in_buf);
 +    s->bytes_per_channel = bytestream_get_byte(&in_buf);
      dimension = bytestream_get_be16(&in_buf);
      s->width  = bytestream_get_be16(&in_buf);
      s->height = bytestream_get_be16(&in_buf);
      s->depth  = bytestream_get_be16(&in_buf);

 -    if (bytes_per_channel != 1) {
 +    if (s->bytes_per_channel != 1 && (s->bytes_per_channel != 2 || rle))
 {
          av_log(avctx, AV_LOG_ERROR, "wrong channel number\n");
          return -1;
      }
 @@ -189,10 +191,10 @@ static int decode_frame(AVCodecContext *
      }

      if (s->depth == SGI_GRAYSCALE) {
 -        avctx->pix_fmt = PIX_FMT_GRAY8;
 +        avctx->pix_fmt = s->bytes_per_channel == 2 ? PIX_FMT_GRAY16BE :
 PIX_FMT_GRAY8;
      } else if (s->depth == SGI_RGB) {
 -        avctx->pix_fmt = PIX_FMT_RGB24;
 -    } else if (s->depth == SGI_RGBA) {
 +        avctx->pix_fmt = s->bytes_per_channel == 2 ? PIX_FMT_RGB48BE :
 PIX_FMT_RGB24;
 +    } else if (s->depth == SGI_RGBA && s->bytes_per_channel == 1) {
          avctx->pix_fmt = PIX_FMT_RGBA;
      } else {
          av_log(avctx, AV_LOG_ERROR, "wrong picture format\n");
 }}}

 {{{
 C:\>ffmpeg -i 2.sgi out_2.tif
 ffmpeg version N-36492-g7f83db3, Copyright (c) 2000-2012 the FFmpeg
 developers
   built on Jan  5 2012 01:57:12 with gcc 4.6.2
   configuration: --enable-gpl --enable-version3 --disable-w32threads
 --enable-ru
 ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-
 libope
 ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-
 libgsm --en
 able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-
 libschroedinger -
 -enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-
 amrwben
 c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs
 --enable-
 libxvid --enable-zlib
   libavutil      51. 34.100 / 51. 34.100
   libavcodec     53. 53.100 / 53. 53.100
   libavformat    53. 29.100 / 53. 29.100
   libavdevice    53.  4.100 / 53.  4.100
   libavfilter     2. 57.101 /  2. 57.101
   libswscale      2.  1.100 /  2.  1.100
   libswresample   0.  5.100 /  0.  5.100
   libpostproc    51.  2.100 / 51.  2.100
 Input #0, image2, from '2.sgi':
   Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: sgi, rgb24, 1024x768, 25 tbr, 25 tbn, 25 tbc
 [buffer @ 020F14A0] w:1024 h:768 pixfmt:rgb24 tb:1/1000000 sar:0/1
 sws_param:
 Output #0, image2, to 'out_2.tif':
   Metadata:
     encoder         : Lavf53.29.100
     Stream #0:0: Video: tiff, rgb24, 1024x768, q=2-31, 200 kb/s, 90k tbn,
 25 tbc

 Stream mapping:
   Stream #0:0 -> #0:0 (sgi -> tiff)
 Press [q] to stop, [?] for help
 frame=    1 fps=  0 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=
 0.0kbits/
 s
 video:2325kB audio:0kB global headers:0kB muxing overhead -100.000000%
 }}}

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/899>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list