[FFmpeg-devel] [PATCH] CD+G Demuxer & Decoder
Reimar Döffinger
Reimar.Doeffinger
Sun Nov 22 22:03:53 CET 2009
On Sun, Nov 22, 2009 at 12:39:30PM -0800, Michael Tison wrote:
> +static void cdg_write_frame(CDGraphicsContext *cc, uint8_t *dst, int h) {
> + int i, j, off;
> +
> + for(j = 0; j < CDG_FULL_HEIGHT; j++) {
> + for(i = 0, off = 0; i < CDG_FULL_WIDTH; i++, off+=3) {
> + dst[j*cc->frame.linesize[0] + off] = cc->colortbl[cc->surface[i][j]] >> 16;
> + dst[j*cc->frame.linesize[0] + off+1] = cc->colortbl[cc->surface[i][j]] >> 8;
> + dst[j*cc->frame.linesize[0] + off+2] = cc->colortbl[cc->surface[i][j]];
> + }
> + }
> +}
That's obviously a paletted format, you should decode it as such and not convert it
in the decoder.
And tabs are not allowed.
> + result = url_fsize(pb);
> + if(result < 0)
> + return AVERROR_INVALIDDATA;
I see no reason for this, CDG files should play fine when streamed, e.g. via stdin.
> + ret = av_new_packet(pkt, CDG_PACKET_SIZE);
> + if(ret < 0)
> + return ret;
> +
> + pkt->pos = url_ftell(pb);
> +
> + ret = get_buffer(pb, pkt->data, CDG_PACKET_SIZE);
> + if(ret <= 0 || pb->eof_reached) {
> + av_free_packet(pkt);
> + return (pb->eof_reached == 1) ? -1 : ret;
> + } else {
> + av_shrink_packet(pkt, ret);
> + if(ret < 0)
> + return ret;
av_get_packet handles all of this and in a more consistent way.
More information about the ffmpeg-devel
mailing list