summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/avcodec.h7
-rw-r--r--libavcodec/parser.c36
-rw-r--r--libavformat/avformat.h2
-rw-r--r--libavformat/avidec.c1
-rw-r--r--libavformat/utils.c5
5 files changed, 35 insertions, 16 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d3ed1a7dea..8fadeb7b29 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -21,8 +21,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+1)
-#define LIBAVCODEC_VERSION 49.0.1
+#define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+2)
+#define LIBAVCODEC_VERSION 49.0.2
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
@@ -2324,6 +2324,9 @@ typedef struct AVCodecParserContext {
int64_t cur_frame_offset[AV_PARSER_PTS_NB];
int64_t cur_frame_pts[AV_PARSER_PTS_NB];
int64_t cur_frame_dts[AV_PARSER_PTS_NB];
+
+ int flags;
+#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
} AVCodecParserContext;
typedef struct AVCodecParser {
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 280bb45f57..ed620dbefc 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -429,13 +429,18 @@ static int mpegvideo_parse(AVCodecParserContext *s,
ParseContext1 *pc1 = s->priv_data;
ParseContext *pc= &pc1->pc;
int next;
-
- next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
-
- if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
+
+ if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
+ next= buf_size;
+ }else{
+ next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
+
}
/* we have a full frame : we just parse the first few MPEG headers
to have the full timing information. The time take by this
@@ -506,6 +511,7 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1,
if (s->width) {
avcodec_set_dimensions(avctx, s->width, s->height);
}
+ s1->pict_type= s->pict_type;
pc->first_picture = 0;
return ret;
}
@@ -529,12 +535,16 @@ static int mpeg4video_parse(AVCodecParserContext *s,
ParseContext *pc = s->priv_data;
int next;
- next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
-
- if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
+ if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
+ next= buf_size;
+ }else{
+ next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
}
av_mpeg4_decode_header(s, avctx, buf, buf_size);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2b3937852a..e891b9768d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -248,7 +248,7 @@ typedef struct AVStream {
char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
/* av_read_frame() support */
- int need_parsing;
+ int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
struct AVCodecParserContext *parser;
int64_t cur_dts;
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 15bd18a375..01b1a9d8c9 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -302,6 +302,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
if (st->codec->codec_id == CODEC_ID_XAN_WC4)
xan_video = 1;
+ st->need_parsing = 2; //only parse headers dont do slower repacketization, this is needed to get the pict type which is needed for generating correct pts
// url_fskip(pb, size - 5 * 4);
break;
case CODEC_TYPE_AUDIO:
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5a81ee0680..eb19eea527 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -927,6 +927,8 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (!st->parser) {
/* no parser available : just output the raw packets */
st->need_parsing = 0;
+ }else if(st->need_parsing == 2){
+ st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
}
@@ -1846,6 +1848,9 @@ int av_find_stream_info(AVFormatContext *ic)
//only for the split stuff
if (!st->parser) {
st->parser = av_parser_init(st->codec->codec_id);
+ if(st->need_parsing == 2 && st->parser){
+ st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
+ }
}
}