[FFmpeg-devel] [PATCH] CD+G Demuxer & Decoder

Michael Niedermayer michaelni
Thu Dec 17 06:15:38 CET 2009


On Tue, Dec 15, 2009 at 07:56:33PM -0800, Michael Tison wrote:
> Revised patch attached.
> 
> On Tue, Dec 15, 2009 at 2:06 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Mon, Dec 14, 2009 at 06:40:17PM -0800, Michael Tison wrote:
> > [...]
> >> + ? ?h_off = ?FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH ?- 1);
> >> + ? ?v_off = ?FFMIN(data[2] & 0x07, CDG_BORDER_HEIGHT - 1);
> >> +
> >> + ? ?/// find the difference and save the offset for cdg_tile_block usage
> >> + ? ?dh_off = h_off - cc->hscroll;
> >> + ? ?dv_off = v_off - cc->vscroll;
> >> + ? ?cc->hscroll = h_off;
> >> + ? ?cc->vscroll = v_off;
> >
> >> +
> >> + ? ?if (vscmd == UP)
> >> + ? ? ? ?vinc = -12;
> >> + ? ?if (vscmd == DOWN)
> >> + ? ? ? ?vinc = 12;
> >> + ? ?if (hscmd == LEFT)
> >> + ? ? ? ?hinc = -6;
> >> + ? ?if (hscmd == RIGHT)
> >> + ? ? ? ?hinc = 6;
> >> + ? ?vinc += dv_off;
> >> + ? ?hinc += dh_off;
> >> +
> >> + ? ?if (!hinc && !vinc)
> >> + ? ? ? ?return;
> >
> > if (vscmd == UP)
> > ? ?dv_off -= 12;
> > if (vscmd == DOWN)
> > ? ?dv_off += 12;
> > ...
> > if(!vscmd && !hscmd) (or ==3 i dont know which is the do nothing case)
> > ? ?return
> 
> Compacted.
> 
> > [...]
> >> +static int read_header(AVFormatContext *s, AVFormatParameters *ap)
> >> +{
> >> + ? ?AVStream *vst;
> >> + ? ?int ret;
> >> +
> >> + ? ?vst = av_new_stream(s, 0);
> >> + ? ?if (!vst)
> >> + ? ? ? ?return AVERROR(ENOMEM);
> >> +
> >> + ? ?vst->codec->codec_type = CODEC_TYPE_VIDEO;
> >> + ? ?vst->codec->codec_id ? = CODEC_ID_CDGRAPHICS;
> >> +
> >> + ? ?/// 75 sectors/sec * 4 packets/sector = 300 packets/sec
> >> + ? ?av_set_pts_info(vst, 32, 1, 300);
> >> +
> >
> >> + ? ?ret = url_fsize(s->pb);
> >> + ? ?if (ret < 0)
> >> + ? ? ? ?return ret;
> >
> > i think failing in this case is unreasonable
> 
> Okay makes sense.
> 
> Michael

>  Changelog                |    1 
>  doc/general.texi         |    4 
>  libavcodec/Makefile      |    1 
>  libavcodec/allcodecs.c   |    1 
>  libavcodec/avcodec.h     |    1 
>  libavcodec/cdgraphics.c  |  380 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/Makefile     |    1 
>  libavformat/allformats.c |    1 
>  libavformat/avformat.h   |    2 
>  libavformat/cdg.c        |   66 ++++++++
>  10 files changed, 457 insertions(+), 1 deletion(-)
> ac5acde84756bac6aedb65f2583adcc870d7b60b  cdgraphicsv9.patch

looks ok assuming its tested & works (test against some fuzzer without
it crashing is probably also a good idea)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091217/35667853/attachment.pgp>



More information about the ffmpeg-devel mailing list