[FFmpeg-devel] [PATCH 1/2] lavf/avienc: Simplify palette handling

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Feb 27 17:45:57 CET 2016


On Sat, Feb 27, 2016 at 04:15:10PM +0100, Mats Peterson wrote:
> On 02/27/2016 04:13 PM, Mats Peterson wrote:
> >On 02/27/2016 04:08 PM, Mats Peterson wrote:
> >>On 02/27/2016 04:07 PM, Mats Peterson wrote:
> >>>On 02/27/2016 04:00 PM, Reimar Döffinger wrote:
> >>>>On Sat, Feb 27, 2016 at 03:57:06PM +0100, Mats Peterson wrote:
> >>>>>On 02/27/2016 03:37 PM, Mats Peterson wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>_______________________________________________
> >>>>>>ffmpeg-devel mailing list
> >>>>>>ffmpeg-devel at ffmpeg.org
> >>>>>>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>>>>>
> >>>>>
> >>>>>I suppose this is what you mean, Reimar. Treating the palette, if a
> >>>>>packet
> >>>>>contains one at the end of the video data, as being AVPALETTE_SIZE
> >>>>>bytes
> >>>>>exclusively.
> >>>>
> >>>>Well, actually not really.
> >>>>If the palette is part of input frame it should be sent as side
> >>>>data.
> >>>>I am not sure where this variant comes from.
> >>>>It might be that it should just be written as is.
> >>>>Or even if the palette needs to be split it might be
> >>>>necessary to auto-detect the palette size via
> >>>>packet size - (width*height*bits per pixel)/8.
> >>>>But as said, I am fairly unclear on what case that
> >>>>code is supposed to handle.
> >>>>_______________________________________________
> >>>>ffmpeg-devel mailing list
> >>>>ffmpeg-devel at ffmpeg.org
> >>>>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>>>
> >>>
> >>>I agree that it should be stored in a side data packet myself normally,
> >>>and that this is a somewhat weird construction. It probably has to do
> >>>with the nut format originally, which stores raw palettized data after
> >>>the video data in the packets. Anyway, I have accepted the facts. For
> >>>the record, the new ff_reshuffle_raw_rgb() function written by Michael
> >>>in lavf/rawutils.c that aligns strides properly for AVI and QuickTime,
> >>>will set a CONTAINS_PAL flag if the packet size is larger than the
> >>>actual video data. He has hardcoded the palette size to 1024 bytes in
> >>>that file.
> >>>
> >>>Mats
> >>>
> >>
> >>The nut format stores the PALETTE after the video data in the packets,
> >>nothing else :)
> >>
> >
> >In any case, on muxing, the packets will have the palette after the
> >video data in the packets, whether it's AVI or QuickTime. Neither
> >avienc.c or movenc.c uses any side data packets for the palette.
> >
> >Michael's intention has been to enable palette switching in the middle
> >of the stream, hence storage of the palette in each packet, and AVI
> >supports it by using the 'xxpc' chunks in the video data. It is also
> >implemented by now.
> >
> >Mats
> >
> 
> Not that it couldn't be done with side data packets, though.

If it doesn't support side data then the muxers are plain broken.
If the nut muxer stores palette by appending it to the frames,
then the demuxer should split it out into side data.
Note that I am absolutely not a fan of this side data stuff,
but since we already decided to do it like that then that's
the way we need to go, not randomly doing one way in one
place and differently in another, that just makes for unusable
API.
The only reasons to support "palette appended to data" are
1) There are some existing users of the FFmpeg API that rely on it.
   Ideally we should then change it so it works for all muxers, or
   the other way round warn that this is a deprecated way of doing
   things.
2) There are file formats that store it that way and we cannot easily
   split it into side data. Not sure that can really happen.



More information about the ffmpeg-devel mailing list