You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
avcodec/cdgraphics: fix decoded output when seeking to start of file
Also in cdg demuxer do not skip packets data, and remove private context which is not really needed.
This commit is contained in:
@@ -26,10 +26,6 @@
|
||||
#define CDG_COMMAND 0x09
|
||||
#define CDG_MASK 0x3F
|
||||
|
||||
typedef struct CDGContext {
|
||||
int got_first_packet;
|
||||
} CDGContext;
|
||||
|
||||
static int read_header(AVFormatContext *s)
|
||||
{
|
||||
AVStream *vst;
|
||||
@@ -56,26 +52,16 @@ static int read_header(AVFormatContext *s)
|
||||
|
||||
static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
CDGContext *priv = s->priv_data;
|
||||
int ret;
|
||||
|
||||
while (1) {
|
||||
ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
|
||||
if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)
|
||||
break;
|
||||
av_packet_unref(pkt);
|
||||
}
|
||||
|
||||
if (!priv->got_first_packet) {
|
||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||
priv->got_first_packet = 1;
|
||||
}
|
||||
|
||||
ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
|
||||
pkt->stream_index = 0;
|
||||
pkt->dts=
|
||||
pkt->pts= pkt->pos / CDG_PACKET_SIZE;
|
||||
|
||||
if(ret>5 && (pkt->data[0]&0x3F) == 9 && (pkt->data[1]&0x3F)==1 && !(pkt->data[2+2+1] & 0x0F)){
|
||||
if (!pkt->pos || (ret > 5 &&
|
||||
(pkt->data[0] & CDG_MASK) == CDG_COMMAND &&
|
||||
(pkt->data[1] & CDG_MASK) == 1 && !(pkt->data[2+2+1] & 0x0F))) {
|
||||
pkt->flags = AV_PKT_FLAG_KEY;
|
||||
}
|
||||
return ret;
|
||||
@@ -84,7 +70,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
AVInputFormat ff_cdg_demuxer = {
|
||||
.name = "cdg",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("CD Graphics"),
|
||||
.priv_data_size = sizeof(CDGContext),
|
||||
.read_header = read_header,
|
||||
.read_packet = read_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
|
||||
Reference in New Issue
Block a user