[FFmpeg-devel] Ticket 165, grayscale Cinepak in mov

Michael Niedermayer michaelni at gmx.at
Wed Sep 7 12:49:30 CEST 2011


On Wed, Sep 07, 2011 at 06:01:09AM +0200, Michael Niedermayer wrote:
> On Tue, Sep 06, 2011 at 08:20:34PM -0700, Baptiste Coudurier wrote:
> > On 09/06/2011 07:51 PM, Michael Niedermayer wrote:
> > > On Mon, Aug 29, 2011 at 11:22:42PM +0200, Carl Eugen Hoyos wrote:
> > >> Hi!
> > >>
> > >> I had attached this patch to ticket 165, it seems to fix all samples.
> > >>
> > >> Please comment, Carl Eugen
> > > 
> > >>  mov.c |    3 ++-
> > >>  1 file changed, 2 insertions(+), 1 deletion(-)
> > >> 1f3316d440d4702ea0f6743d5a3513c8cb502dec  patchmovcinepak.diff
> > > 
> > > in absence of a better solution i think this LGTM
> > > baptiste, whats your oppinon ?
> > 
> > What's wrong with hacking the decoder ?
> 
> that looks like this:
> 
> diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
> index d2e0c26..7f408b9 100644
> --- a/libavcodec/cinepak.c
> +++ b/libavcodec/cinepak.c
> @@ -394,9 +394,9 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx)
>      s->width = (avctx->width + 3) & ~3;
>      s->height = (avctx->height + 3) & ~3;
>      s->sega_film_skip_bytes = -1;  /* uninitialized state */
> -
> +av_log(0,0, "bits %d\n", avctx->bits_per_coded_sample);
>      // check for paletted data
> -    if (avctx->bits_per_coded_sample != 8) {
> +    if (avctx->bits_per_coded_sample != 8 || 1) {
>          s->palette_video = 0;
>          avctx->pix_fmt = PIX_FMT_YUV420P;
>      } else {
> 
> so the else would never be reached, which is likely breaking something
> better suggestions are welcome

heres a better fix:
 diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5464b78..70cd776 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1052,6 +1052,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
                     color_index = 255;
                     color_dec = 256 / (color_count - 1);
                     for (j = 0; j < color_count; j++) {
+                        if (id == CODEC_ID_CINEPAK){
+                            r = g = b = color_count - 1 - color_index;
+                        }else
                         r = g = b = color_index;
                         sc->palette[j] =
                             (r << 16) | (g << 8) | (b);


a fix in the decoder, i dont see how to do, as mov sends a palette
in the grayscale case thats upside down compared to what avi has
in the color case and i dont know how to detect the difference in
the decoder. Especially if one considers a hypothetical stream copy

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110907/6bf6c081/attachment.asc>


More information about the ffmpeg-devel mailing list