[FFmpeg-devel] [PATCH] encoder for adobe's flash ScreenVideo2 codec

Benjamin Larsson banan
Fri Nov 20 16:14:28 CET 2009

Daniel Verkamp wrote:
> On Thu, Jul 23, 2009 at 8:42 AM, Joshua Warner <joshuawarner32 at gmail.com> wrote:
> [...]
>>>>>> I've developed an encoder for Adobe's Flash ScreenVideo2 format
> [...]
> I started on a decoder for this format; attached is my progress so far.
> It correctly decodes the first frame of samples created by the encoder
> from this thread, but it does not implement any of the fancy features
> yet (interframes, diff blocks, custom palettes, zlib priming of either
> variety).
> The official documentation seems to be missing a few points or just
> plain wrong based on comparison with the encoder patch; specifically,
> ZlibPrimeCompressPrevious (by my reading of this encoder) does not
> mean that the previous block used zlib priming.  It rather means to
> prime zlib with data from the equivalent block of the previous frame
> before decompressing the current block's data.  This seems like a
> reinvention of zlib's deflate/inflateSetDictionary functionality...
> I'm not sure how to prime it on the decompression side (using
> inflateSetDictionary doesn't work, as far as I can tell, because the
> stream was not actually compressed with a custom dictionary - the
> encoder actually runs the previous block through the compressor,
> discards the result, and then compresses the current block without
> reinitializing the decoder).  It seems like I would need to store the
> zlib state for each block of the previous frame to make this possible,
> but surely that is not how it is intended.
> Anyway, if any intrepid hackers want something to do, have at it - I
> probably will not do any serious work on it in the near future.
> Thanks,
> -- Daniel Verkamp

Can you provide some samples that you encoded with the encoder patch? 
One of the main reason we don't have a codec is that we don't have any 
samples. The patch looks ok but it has to at least be able to decode the 
files that the encoder can produce.

> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7ffbd95..ac3b803 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -199,6 +199,7 @@ enum CodecID {
>      CODEC_ID_DPX,
>      CODEC_ID_MAD,
This looks ok. 

> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 27062dc..2be5e2d 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -82,6 +82,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
>      switch(flv_codecid) {
>          case FLV_CODECID_H263  : vcodec->codec_id = CODEC_ID_FLV1   ; break;
>          case FLV_CODECID_SCREEN: vcodec->codec_id = CODEC_ID_FLASHSV; break;
> +        case FLV_CODECID_SCREEN2: vcodec->codec_id = CODEC_ID_FLASHSV2; break;
>          case FLV_CODECID_VP6   : vcodec->codec_id = CODEC_ID_VP6F   ;
>          case FLV_CODECID_VP6A  :
>              if(flv_codecid == FLV_CODECID_VP6A)

This hunk looks ok, but I'm not the maintainer.

Benjamin Larsson

More information about the ffmpeg-devel mailing list