Ticket #1191 (closed defect: fixed)

Opened 14 months ago

Last modified 12 months ago

qt tiff enc: make output compatible with quitcktime

Reported by: ami_stuff Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: mov tif
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

http://ffmpeg.org/trac/ffmpeg/raw-attachment/ticket/1167/j.asf

the output from

ffmpeg -i j.asf -an -vcodec tiff -pix_fmt (any) out.mov

is always identified by quicktime as 24bpp and is decoded incorrectly.

I have found out where is a problem, please look at the attached screenshot.

The left file is an unmodified output from:

ffmpeg -i j.asf -vcodec tiff -pix_fmt gray out.mov

conversion, the right file is modified by me (to values which are present in QT TIFF 256gray generated by QuickTime?) and after this change the file is identified and decoded correctly by QuickTime?.

(for monob 18 FF FF should be repleaced by 01 00 01)

Attachments

qttiff.jpg Download (101.8 KB) - added by ami_stuff 14 months ago.
patchtiffmov.diff Download (1.6 KB) - added by cehoyos 14 months ago.
pal8.bmp Download (769.1 KB) - added by ami_stuff 14 months ago.
pal8.mov Download (759.5 KB) - added by ami_stuff 14 months ago.
patchpngtga.diff Download (1.8 KB) - added by cehoyos 14 months ago.
gray.mov Download (19.9 KB) - added by ami_stuff 12 months ago.

Change History

Changed 14 months ago by ami_stuff

comment:1 Changed 14 months ago by ami_stuff

the same problem (and fix) for -vcodec png and targa

comment:2 Changed 14 months ago by cehoyos

  • Keywords mov tif added
  • Version changed from unspecified to git-master

Does it work with "28 FF FF"?

The relevant line in libavformat/movenc.c is 1064, "avio_wb16(pb, 0x18); /* Reserved */"

comment:3 Changed 14 months ago by ami_stuff

yes it seems enough to modify only this one value to number of bpp to make the file correctly recognized by qt

monob/w: 01
gray: 28
rgb: 18
rgba: 20
pal8: 08 (wrong palette/colors, probably unrelated issue)

Changed 14 months ago by cehoyos

comment:4 Changed 14 months ago by cehoyos

  • Status changed from new to open

Could you test if attached patch fixes RGBA and monob?
Does it also work for RGB48 and RGBA64?

comment:5 Changed 14 months ago by ami_stuff

monob/w, rgb24 and rgba deocdes correctly with attached patch

pal8 have wrong colors (see pal8.bmp), maybe problem with endianness?

rgb48/64 is not supported by qt even in tiff

Changed 14 months ago by ami_stuff

Changed 14 months ago by ami_stuff

Changed 14 months ago by cehoyos

comment:6 Changed 14 months ago by cehoyos

  • Status changed from open to closed
  • Resolution set to fixed

tiff should be fixed as far as possible, could you test attached patch with png and targa?

comment:7 Changed 14 months ago by ami_stuff

targa:

qt decodes correctly all modes of targa except rgb555le, but when I add

    case PIX_FMT_RGB555LE:
+        avctx->bits_per_coded_sample = 16;
        pkt->data[2]  = TGA_RGB;    /* uncompresses true-color image */
        pkt->data[16] = 16;         /* bpp */
        break;

then I get correct output.

The problem is that avctx->bits_per_coded_sample is set to 15 for rgb555le mode:

    avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
+    av_log(avctx, AV_LOG_INFO, "bits_per_coded_sample: %d\n", avctx->bits_per_coded_sample);
    switch(avctx->pix_fmt) {

png:

qt decodec correctly monob/rgb24/rgba/gray/pal8 (wrong colors)

gray16/rgb48/rgba64 doesn't work (black screen)

comment:8 Changed 14 months ago by cehoyos

Could you test ffmpeg -i input -vcodec png out.avi with WMP and different pix_fmts with and without this patch (if this works at all with -pix_fmt rgb24)?
 http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/143645

comment:9 Changed 14 months ago by ami_stuff

I have installed CorePNG codec, so WMP is able to play output avi from this:

ffmpeg -i test.bmp -pix_fmt <format> -vtag PNG1 out.avi

and WMP plays correctly (with and without your patch) monob/gray/pal8/rgb24 and rgba.

VirtualDub? is not so happy:

monob/gray/pal8 decodes incorrectly

rgb24/rgba: first frame decodes ok, next frames are upside-down

but this in unrealted to your patch, so in short your patch shouldn't break anything for at least CorePNG codec in AVI.

comment:10 Changed 12 months ago by richardpl

Are you sure that for gray8 in mov bpp is set to 0x28 (40)?

Changed 12 months ago by ami_stuff

comment:11 Changed 12 months ago by ami_stuff

I attached qt tiff 256 grays.

Note: See TracTickets for help on using tickets.