summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-09-10 00:39:47 +0200
committerPaul B Mahol <onemda@gmail.com>2020-09-13 16:05:01 +0200
commite1da139a331de753867dc3af2da0d8341f9d2ed5 (patch)
treec6d434094819b5a666ddaf419a31d5da4ffbbfc8 /libavformat
parent55af1807f7606225616e0a64a2142aa560232887 (diff)
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.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/cdg.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/libavformat/cdg.c b/libavformat/cdg.c
index f933819d57..8fb287a998 100644
--- a/libavformat/cdg.c
+++ b/libavformat/cdg.c
@@ -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,