[FFmpeg-trac] #226(undetermined:new): QT RLE 1bpp support is buggy

FFmpeg trac at avcodec.org
Fri May 20 23:36:23 CEST 2011


#226: QT RLE 1bpp support is buggy
--------------------------+--------------------------
 Reporter:  ami_stuff     |        Type:  defect
   Status:  new           |    Priority:  normal
Component:  undetermined  |     Version:  unspecified
 Keywords:                |  Blocked By:
 Blocking:                |  Reproduced:  0
 Analyzed:  0             |
--------------------------+--------------------------
 (issue 1529)

 {{{
 Author: ami_stuff       Date: 2009-11-07.19:32:36

 Attached QT RLE file decodes correctly except some gfx bugs:

 1. at the beginning in the output AVI file there are visible white lines
 2. there is visibe white line at the top of the screen

 C:\>ffmpeg -i qt_rle_bw.mov -vcodec huffyuv qt_rle_bw.avi
 FFmpeg version SVN-r20467, Copyright (c) 2000-2009 Fabrice Bellard, et al.
   built on Nov  6 2009 04:04:33 with gcc 4.2.4
   configuration: --enable-memalign-hack --prefix=/mingw --cross-
 prefix=i686-ming
 w32- --cc=ccache-i686-mingw32-gcc --target-os=mingw32 --arch=i686
 --cpu=i686 --e
 nable-avisynth --enable-gpl --enable-version3 --enable-zlib --enable-bzlib
 --ena
 ble-libgsm --enable-libfaad --enable-pthreads --enable-libvorbis --enable-
 libthe
 ora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg --enable-
 libxvid
 --enable-libschroedinger --enable-libx264 --enable-libopencore_amrwb
 --enable-li
 bopencore_amrnb
   libavutil     50. 3. 0 / 50. 3. 0
   libavcodec    52.37. 1 / 52.37. 1
   libavformat   52.39. 2 / 52.39. 2
   libavdevice   52. 2. 0 / 52. 2. 0
   libswscale     0. 7. 1 /  0. 7. 1

 Seems stream 0 codec frame rate differs from container frame rate:
 1000000.00 (1
 000000/1) -> 15.00 (500000/33333)
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'qt_rle_bw.mov':
   Duration: 00:00:12.64, start: 0.000000, bitrate: 1197 kb/s
     Stream #0.0(eng): Video: qtrle, monow, 320x240, 1195 kb/s, 15 tbr,
 1000k tbn
 , 1000k tbc
   Metadata
     major_brand     : qt
     minor_version   : 537199360
     compatible_brands: qt
 Output #0, avi, to 'qt_rle_bw.avi':
     Stream #0.0(eng): Video: huffyuv, yuv422p, 320x240, q=2-31, 200 kb/s,
 15 tbn
 , 15 tbc
 Stream mapping:
   Stream #0.0 -> #0.0
 Press [q] to stop encoding
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11522, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11522, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11532, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 44 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11526, pixel_limit = 11520
     Last message repeated 1 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11556, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 3 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11550, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11534, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 12 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11528, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 19 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11532, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 6 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11536, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 4 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11552, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11528, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 14 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11556, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 6 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11554, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 1 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11526, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 9 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11530, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11522, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11540, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 2 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 3 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11532, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11560, pixel_limit = 11520
     Last message repeated 13 times10410kB time=11.20 bitrate=7614.3kbits/s
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11526, pixel_limit = 11520
     Last message repeated 1 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
     Last message repeated 1 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11534, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11522, pixel_limit = 11520
     Last message repeated 4 times
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11524, pixel_limit = 11520
 [qtrle @ 0x1a08480]Problem: pixel_ptr = 11532, pixel_limit = 11520
 frame=  190 fps=  0 q=0.0 Lsize=   11759kB time=12.67
 bitrate=7605.2kbits/s
 video:11749kB audio:0kB global headers:0kB muxing overhead 0.085112%
 }}}

 {{{
 Author: cehoyos         Date: 2009-12-29.20:41:05

 Since the sample decodes, I believe this is a minor issue.
 }}}



 XAnim decodes the sample correctly:


 {{{
 /********************* * * * *******************************************/
 xaULONG QT_Decode_RLE1(image,delta,dsize,dec_info)
 xaUBYTE *image;         /* Image Buffer. */
 xaUBYTE *delta;         /* delta data. */
 xaULONG dsize;          /* delta size */
 XA_DEC_INFO *dec_info;  /* Decoder Info Header */
 { xaULONG imagex = dec_info->imagex;    xaULONG imagey = dec_info->imagey;
   xaULONG map_flag = dec_info->map_flag;        xaULONG *map =
 dec_info->map;
   xaLONG x,y,d,lines; /* xaLONG min_x,max_x,min_y,max_y; */
   xaUBYTE *dptr;

   dptr = delta;
   dptr += 4;    /* skip codec size */
   d = (*dptr++) << 8;  d |= *dptr++;   /* read code either 0008 or 0000 */
   if (dsize < 8) /* NOP */
   {
     dec_info->xs = dec_info->ys = dec_info->xe = dec_info->ye = 0;
     return(ACT_DLTA_NOP);
   }
   if (d & 0x0008) /* Header present */
   {
     y = (*dptr++) << 8; y |= *dptr++;           /* start line */
     dptr += 2;                                  /* unknown */
     lines = (*dptr++) << 8; lines |= *dptr++;   /* number of lines */
     dptr += 2;                                  /* unknown */
   }
   else { y = 0; lines = imagey; }
   x = 0; y--; lines++;
   while(lines)                          /* loop thru lines */
   {
     xaULONG d,xskip,cnt;

     xskip = *dptr++;                            /* skip x pixels */
     cnt = *dptr++;                              /* RLE code */
     if (cnt == 0) break;                        /* exit */

 /* this can be removed */
     if ((xskip == 0x80) && (cnt == 0x00))  /* end of codec */
     {
           lines = 0; y++; x = 0;
     }
     else if ((xskip == 0x80) && (cnt == 0xff)) /* skip line */
         {lines--; y++; x = 0; }
     else
     {
       if (xskip & 0x80) {lines--; y++; x = xskip & 0x7f;}
       else x += xskip;

       if (cnt < 0x80)                           /* run of data */
       {
         xaUBYTE *bptr; xaUSHORT *sptr; xaULONG *lptr;
         if ((x11_bytes_pixel==1) || (map_flag==xaFALSE) )
                 bptr = (xaUBYTE *)(image + (y * imagex) + (x << 4) );
         else if (x11_bytes_pixel==2)
                 sptr = (xaUSHORT *)(image + 2*(y * imagex) + (x << 5) );
         else lptr = (xaULONG *)(image + 4*(y * imagex) + (x << 6) );
         x += cnt;
         while(cnt--)
         { xaULONG i,mask;
           d = (*dptr++ << 8); d |= *dptr++;
           mask = 0x8000;
           for(i=0;i<16;i++)
           {
             if (map_flag==xaFALSE)
                 { if (d & mask) *bptr++ = 0;  else *bptr++ = 1; }
             else if (x11_bytes_pixel==1) {if (d & mask)
 *bptr++=(xaUBYTE)map[0];
                                         else *bptr++=(xaUBYTE)map[1];}
             else if (x11_bytes_pixel==2) {if (d & mask) *sptr++
 =(xaUSHORT)map[0];
                                         else *sptr++ =(xaUSHORT)map[1]; }
             else { if (d & mask) *lptr++ = (xaULONG)map[0];
                                         else *lptr++ = (xaULONG)map[1]; }
             mask >>= 1;
           }
         }
       } /* end run */
       else                              /* repeat data */
       {
         xaUBYTE *bptr; xaUSHORT *sptr; xaULONG *lptr;
         if ((x11_bytes_pixel==1) || (map_flag==xaFALSE) )
                 bptr = (xaUBYTE *)(image + (y * imagex) + (x << 4) );
         else if (x11_bytes_pixel==2)
                 sptr = (xaUSHORT *)(image + 2*(y * imagex) + (x << 5) );
         else lptr = (xaULONG *)(image + 4*(y * imagex) + (x << 6) );
         cnt = 0x100 - cnt;
         x += cnt;
         d = (*dptr++ << 8); d |= *dptr++;
         while(cnt--)
         { xaULONG i,mask;
           mask = 0x8000;
           for(i=0;i<16;i++)
           {
             if (map_flag==xaFALSE)
                 { if (d & mask) *bptr++ = 0;  else *bptr++ = 1; }
             else if (x11_bytes_pixel==1) {if (d & mask)
 *bptr++=(xaUBYTE)map[0];
                                         else *bptr++=(xaUBYTE)map[1];}
             else if (x11_bytes_pixel==2) {if (d & mask) *sptr++
 =(xaUSHORT)map[0];
                                         else *sptr++ =(xaUSHORT)map[1]; }
             else { if (d & mask) *lptr++ = (xaULONG)map[0];
                                         else *lptr++ = (xaULONG)map[1]; }
             mask >>= 1;
           }
         }
       } /* end repeat */
     } /* end of code */
   } /* end of lines */
  dec_info->xs = dec_info->ys = 0; dec_info->xe = imagex; dec_info->ye =
 imagey;
  if (map_flag==xaTRUE) return(ACT_DLTA_MAPD);
  else return(ACT_DLTA_NORM);
 }
 }}}

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


More information about the FFmpeg-trac mailing list