[FFmpeg-cvslog] avformat/flvdec: add several error messages to error conditions
ffmpeg | branch: master | Michael Niedermayer | Thu Jan 1 18:03:54 2015 +0100| [5c37ffca59e7eb1b8768f237deb35a9936c1a0a5] | committer: Michael Niedermayer avformat/flvdec: add several error messages to error conditions Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c37ffca59e7eb1b8768f237deb35a9936c1a0a5 --- libavformat/flvdec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 54f2f56..8a4addb 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -405,8 +405,10 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: -if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) +if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) { +av_log(s, AV_LOG_ERROR, "AMF_DATA_TYPE_STRING parsing failed\n"); return -1; +} break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && @@ -421,8 +423,10 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; // if we couldn't skip, bomb out. -if (avio_r8(ioc) != AMF_END_OF_OBJECT) +if (avio_r8(ioc) != AMF_END_OF_OBJECT) { +av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_OBJECT\n"); return -1; +} break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: @@ -438,7 +442,10 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) +if (avio_r8(ioc) != AMF_END_OF_OBJECT) { +av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_MIXEDARRAY\n"); return -1; +} break; case AMF_DATA_TYPE_ARRAY: { @@ -455,6 +462,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, avio_skip(ioc, 8 + 2); // timestamp (double) and UTC offset (int16) break; default:// unsupported type, we couldn't skip +av_log(s, AV_LOG_ERROR, "unsupported amf type %d\n", amf_type); return -1; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/flvdec: Increase string array size
ffmpeg | branch: master | Michael Niedermayer | Thu Jan 1 18:15:16 2015 +0100| [eb767a276bfdb9a0493bdb0b38203638230b7ccb] | committer: Michael Niedermayer avformat/flvdec: Increase string array size Fixes parsing httphostheader of Scarlatti\,\ Pieter-Jan\ Belder\ -\ Sonata\ K113\ in\ A\ major\ -\ Alle.flv Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb767a276bfdb9a0493bdb0b38203638230b7ccb --- libavformat/flvdec.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 993b5a2..dc0edf2 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -390,7 +390,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; -char str_val[256]; +char str_val[1024]; double num_val; num_val = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/flvdec: do not inject dts= 0 metadata packets which failed to be parsed into a new data stream
ffmpeg | branch: master | Michael Niedermayer | Thu Jan 1 18:07:24 2015 +0100| [322f0f5960a743cac47252d90a0f1ea7a025feff] | committer: Michael Niedermayer avformat/flvdec: do not inject dts=0 metadata packets which failed to be parsed into a new data stream Such data streams (which then contain no other packets except the faulty one) confuse some user applications, like VLC Works around vlcticket 12389 Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=322f0f5960a743cac47252d90a0f1ea7a025feff --- libavformat/flvdec.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 8a4addb..993b5a2 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -566,13 +566,13 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) type = avio_r8(ioc); if (type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0) -return -1; +return 2; if (!strcmp(buffer, "onTextData")) return 1; if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) -return -1; +return 2; // find the streams now so that amf_parse_object doesn't need to do // the lookup every time it is called. @@ -830,7 +830,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) stream_type=FLV_STREAM_TYPE_DATA; if (size > 13 + 1 + 4 && dts == 0) { // Header-type metadata stuff meta_pos = avio_tell(s->pb); -if (flv_read_metabody(s, next) == 0) { +if (flv_read_metabody(s, next) <= 0) { goto skip; } avio_seek(s->pb, meta_pos, SEEK_SET); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/flvdec: use named identifier instead of literal numbers as return values
ffmpeg | branch: master | Michael Niedermayer | Thu Jan 1 19:14:06 2015 +0100| [efc4bfc195dab6efa77b444eac9313df4596a922] | committer: Michael Niedermayer avformat/flvdec: use named identifier instead of literal numbers as return values Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=efc4bfc195dab6efa77b444eac9313df4596a922 --- libavformat/flvdec.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index dc0edf2..c13c0e4 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -546,6 +546,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, return 0; } +#define TYPE_ONTEXTDATA 1 +#define TYPE_UNKNOWN 2 + static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) { AMFDataType type; @@ -566,13 +569,13 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) type = avio_r8(ioc); if (type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0) -return 2; +return TYPE_UNKNOWN; if (!strcmp(buffer, "onTextData")) -return 1; +return TYPE_ONTEXTDATA; if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) -return 2; +return TYPE_UNKNOWN; // find the streams now so that amf_parse_object doesn't need to do // the lookup every time it is called. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffplay: remove unused no_background from videostate
ffmpeg | branch: master | Marton Balint | Sat Nov 8 16:59:13 2014 +0100| [82928656b134b48599e1b7ee32fde1aaf81ea9f6] | committer: Marton Balint ffplay: remove unused no_background from videostate Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82928656b134b48599e1b7ee32fde1aaf81ea9f6 --- ffplay.c |1 - 1 file changed, 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 507617e..bd156df 100644 --- a/ffplay.c +++ b/ffplay.c @@ -198,7 +198,6 @@ typedef struct VideoState { SDL_Thread *video_tid; SDL_Thread *audio_tid; AVInputFormat *iformat; -int no_background; int abort_request; int force_refresh; int paused; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffplay: remove flushed state from decoder context
ffmpeg | branch: master | Marton Balint | Thu Oct 30 01:50:22 2014 +0100| [8c1f5fb0ae1934b1852a190bc7b252064a6330d0] | committer: Marton Balint ffplay: remove flushed state from decoder context Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c1f5fb0ae1934b1852a190bc7b252064a6330d0 --- ffplay.c |4 1 file changed, 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 1914a66..507617e 100644 --- a/ffplay.c +++ b/ffplay.c @@ -185,7 +185,6 @@ typedef struct Decoder { AVCodecContext *avctx; int pkt_serial; int finished; -int flushed; int packet_pending; SDL_cond *empty_queue_cond; int64_t start_pts; @@ -548,8 +547,6 @@ static void decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { int got_frame = 0; -d->flushed = 0; - do { int ret = -1; @@ -566,7 +563,6 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { if (pkt.data == flush_pkt.data) { avcodec_flush_buffers(d->avctx); d->finished = 0; -d->flushed = 1; d->next_pts = d->start_pts; d->next_pts_tb = d->start_pts_tb; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffplay: dump format before selecting streams
ffmpeg | branch: master | Marton Balint | Sat Dec 20 20:44:39 2014 +0100| [46aa75eea1bd68c0e1224ef9ce640b05818572f9] | committer: Marton Balint ffplay: dump format before selecting streams This helps the user to see the available streams just before the error message if the stream specifiers do not match. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46aa75eea1bd68c0e1224ef9ce640b05818572f9 --- ffplay.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffplay.c b/ffplay.c index 655af6d..72ec35d 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2959,6 +2959,9 @@ static int read_thread(void *arg) is->realtime = is_realtime(ic); +if (show_status) +av_dump_format(ic, 0, is->filename, 0); + for (i = 0; i < ic->nb_streams; i++) { AVStream *st = ic->streams[i]; enum AVMediaType type = st->codec->codec_type; @@ -2992,9 +2995,6 @@ static int read_thread(void *arg) st_index[AVMEDIA_TYPE_AUDIO] : st_index[AVMEDIA_TYPE_VIDEO]), NULL, 0); -if (show_status) { -av_dump_format(ic, 0, is->filename, 0); -} is->show_mode = show_mode; if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge remote-tracking branch 'cus/stable'
ffmpeg | branch: master | Michael Niedermayer | Thu Jan 1 20:19:51 2015 +0100| [8009a51f7bbd90e2a8806be2d8f49f0684037bdb] | committer: Michael Niedermayer Merge remote-tracking branch 'cus/stable' * cus/stable: ffplay: dump format before selecting streams ffplay: add support for stream specifiers in -ast, -vst, -sst options ffplay: remove unused no_background from videostate ffplay: remove flushed state from decoder context Merged-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8009a51f7bbd90e2a8806be2d8f49f0684037bdb --- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffplay: add support for stream specifiers in -ast, -vst, -sst options
ffmpeg | branch: master | Marton Balint | Sat Dec 20 18:18:48 2014 +0100| [5e7dcb0491cc9c6d8c6f964605fadcbb10831ff9] | committer: Marton Balint ffplay: add support for stream specifiers in -ast, -vst, -sst options Also fix the outdated documentation of these options. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e7dcb0491cc9c6d8c6f964605fadcbb10831ff9 --- doc/ffplay.texi | 29 ++--- ffplay.c| 35 ++- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 556fc39..45731a2 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -124,21 +124,20 @@ master clock is used to control audio-video synchronization. Most media players use audio as master clock, but in some cases (streaming or high quality broadcast) it is necessary to change that. This option is mainly used for debugging purposes. -@item -ast @var{audio_stream_number} -Select the desired audio stream number, counting from 0. The number -refers to the list of all the input audio streams. If it is greater -than the number of audio streams minus one, then the last one is -selected, if it is negative the audio playback is disabled. -@item -vst @var{video_stream_number} -Select the desired video stream number, counting from 0. The number -refers to the list of all the input video streams. If it is greater -than the number of video streams minus one, then the last one is -selected, if it is negative the video playback is disabled. -@item -sst @var{subtitle_stream_number} -Select the desired subtitle stream number, counting from 0. The number -refers to the list of all the input subtitle streams. If it is greater -than the number of subtitle streams minus one, then the last one is -selected, if it is negative the subtitle rendering is disabled. +@item -ast @var{audio_stream_specifier} +Select the desired audio stream using the given stream specifier. The stream +specifiers are described in the @ref{Stream specifiers} chapter. If this option +is not specified, the "best" audio stream is selected in the program of the +already selected video stream. +@item -vst @var{video_stream_specifier} +Select the desired video stream using the given stream specifier. The stream +specifiers are described in the @ref{Stream specifiers} chapter. If this option +is not specified, the "best" video stream is selected. +@item -sst @var{subtitle_stream_specifier} +Select the desired subtitle stream using the given stream specifier. The stream +specifiers are described in the @ref{Stream specifiers} chapter. If this option +is not specified, the "best" subtitle stream is selected in the program of the +already selected video or audio stream. @item -autoexit Exit when video is done playing. @item -exitonkeydown diff --git a/ffplay.c b/ffplay.c index bd156df..655af6d 100644 --- a/ffplay.c +++ b/ffplay.c @@ -312,11 +312,7 @@ static int screen_height = 0; static int audio_disable; static int video_disable; static int subtitle_disable; -static int wanted_stream[AVMEDIA_TYPE_NB] = { -[AVMEDIA_TYPE_AUDIO]= -1, -[AVMEDIA_TYPE_VIDEO]= -1, -[AVMEDIA_TYPE_SUBTITLE] = -1, -}; +static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = {0}; static int seek_by_bytes = -1; static int display_disable; static int show_status = 1; @@ -2963,22 +2959,35 @@ static int read_thread(void *arg) is->realtime = is_realtime(ic); -for (i = 0; i < ic->nb_streams; i++) -ic->streams[i]->discard = AVDISCARD_ALL; +for (i = 0; i < ic->nb_streams; i++) { +AVStream *st = ic->streams[i]; +enum AVMediaType type = st->codec->codec_type; +st->discard = AVDISCARD_ALL; +if (wanted_stream_spec[type] && st_index[type] == -1) +if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0) +st_index[type] = i; +} +for (i = 0; i < AVMEDIA_TYPE_NB; i++) { +if (wanted_stream_spec[i] && st_index[i] == -1) { +av_log(NULL, AV_LOG_ERROR, "Stream specifier %s does not match any %s stream\n", wanted_stream_spec[i], av_get_media_type_string(i)); +st_index[i] = INT_MAX; +} +} + if (!video_disable) st_index[AVMEDIA_TYPE_VIDEO] = av_find_best_stream(ic, AVMEDIA_TYPE_VIDEO, -wanted_stream[AVMEDIA_TYPE_VIDEO], -1, NULL, 0); +st_index[AVMEDIA_TYPE_VIDEO], -1, NULL, 0); if (!audio_disable) st_index[AVMEDIA_TYPE_AUDIO] = av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO, -wanted_stream[AVMEDIA_TYPE_AUDIO], +st_index[AVMEDIA_TYPE_AUDIO], st_index[AVMEDIA_TYPE_VIDEO], NULL, 0); if (!video_disable && !subtitle_disable) st_index[AVMEDIA_TYPE_SUBTITLE]
[FFmpeg-cvslog] avformat/flvdec: remove duplicated line error
ffmpeg | branch: master | Clément Bœsch | Thu Jan 1 22:09:21 2015 +0100| [6a29499b95bb1e7ab11bc9dfcac22da5825bbc0f] | committer: Clément Bœsch avformat/flvdec: remove duplicated line error Fix typo regression since 5c37ffca59e7eb1b8768f237deb35a9936c1a0a5 Found-By: cousin_luigi > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a29499b95bb1e7ab11bc9dfcac22da5825bbc0f --- libavformat/flvdec.c |1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index c13c0e4..572268f 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -441,7 +441,6 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; -if (avio_r8(ioc) != AMF_END_OF_OBJECT) if (avio_r8(ioc) != AMF_END_OF_OBJECT) { av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_MIXEDARRAY\n"); return -1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/mpeg12dec: Check actual aspect ratio instead of aspect_ratio_info
ffmpeg | branch: master | Michael Niedermayer | Fri Jan 2 03:18:54 2015 +0100| [75cc57f73f9aee8721a101b3c6ef85312ea9e54c] | committer: Michael Niedermayer avcodec/mpeg12dec: Check actual aspect ratio instead of aspect_ratio_info Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=75cc57f73f9aee8721a101b3c6ef85312ea9e54c --- libavcodec/mpeg12dec.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 3f7b2c3..f7e57f9 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -59,7 +59,7 @@ typedef struct Mpeg1Context { uint8_t afd; int has_afd; int slice_count; -int save_aspect_info; +AVRational save_aspect; int save_width, save_height, save_progressive_seq; AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ @@ -1322,7 +1322,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) avctx->coded_height != s->height || s1->save_width != s->width|| s1->save_height != s->height || -s1->save_aspect_info != s->aspect_ratio_info|| +av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) || (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) || 0) { if (s1->mpeg_enc_ctx_allocated) { @@ -1343,7 +1343,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) (s->bit_rate != 0x3*400 || s->vbv_delay != 0x)) { avctx->bit_rate = s->bit_rate; } -s1->save_aspect_info = s->aspect_ratio_info; +s1->save_aspect = s->avctx->sample_aspect_ratio; s1->save_width = s->width; s1->save_height = s->height; s1->save_progressive_seq = s->progressive_sequence; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/mpeg12dec: Move user data debug code out of unrelated if ( buf_size > 29)
ffmpeg | branch: master | Michael Niedermayer | Fri Jan 2 02:27:18 2015 +0100| [aeb36fd2072e9612fefddfaf1041b886fa1efdc0] | committer: Michael Niedermayer avcodec/mpeg12dec: Move user data debug code out of unrelated if (buf_size > 29) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aeb36fd2072e9612fefddfaf1041b886fa1efdc0 --- libavcodec/mpeg12dec.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 6568806..e156522 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2299,19 +2299,21 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, const uint8_t *buf_end = p + buf_size; Mpeg1Context *s1 = avctx->priv_data; +#if 0 +int i; +for(i=0; !(!p[i-2] && !p[i-1] && p[i]==1) && i 29){ int i; for(i=0; i<20; i++) if (!memcmp(p+i, "\0TMPGEXS\0", 9)){ s->tmpgexs= 1; } - -/*for(i=0; !(!p[i-2] && !p[i-1] && p[i]==1) && i= 5 && p[0] == 'D' && p[1] == 'T' && p[2] == 'G' && p[3] == '1') { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/mpeg12dec: Recalculate SAR unconditionally
ffmpeg | branch: master | Michael Niedermayer | Fri Jan 2 02:33:34 2015 +0100| [1010b36d8672d891e77aa713e07ff749e8b0797f] | committer: Michael Niedermayer avcodec/mpeg12dec: Recalculate SAR unconditionally Fixes Ticket4161 Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1010b36d8672d891e77aa713e07ff749e8b0797f --- libavcodec/mpeg12dec.c | 84 +--- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index e156522..3f7b2c3 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1273,6 +1273,50 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) uint8_t old_permutation[64]; int ret; +if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { +// MPEG-1 aspect +avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255); +} else { // MPEG-2 +// MPEG-2 aspect +if (s->aspect_ratio_info > 1) { +AVRational dar = +av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], + (AVRational) { s1->pan_scan.width, + s1->pan_scan.height }), + (AVRational) { s->width, s->height }); + +/* We ignore the spec here and guess a bit as reality does not + * match the spec, see for example res_change_ffmpeg_aspect.ts + * and sequence-display-aspect.mpg. + * issue1613, 621, 562 */ +if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) || +(av_cmp_q(dar, (AVRational) { 4, 3 }) && + av_cmp_q(dar, (AVRational) { 16, 9 }))) { +s->avctx->sample_aspect_ratio = +av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], + (AVRational) { s->width, s->height }); +} else { +s->avctx->sample_aspect_ratio = +av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], + (AVRational) { s1->pan_scan.width, s1->pan_scan.height }); +// issue1613 4/3 16/9 -> 16/9 +// res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3 +// widescreen-issue562.mpg 4/3 16/9 -> 16/9 +//s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height}); +av_dlog(avctx, "A %d/%d\n", +ff_mpeg2_aspect[s->aspect_ratio_info].num, +ff_mpeg2_aspect[s->aspect_ratio_info].den); +av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num, +s->avctx->sample_aspect_ratio.den); +} +} else { +s->avctx->sample_aspect_ratio = +ff_mpeg2_aspect[s->aspect_ratio_info]; +} +} // MPEG-2 + +ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio); + if ((s1->mpeg_enc_ctx_allocated == 0) || avctx->coded_width != s->width|| avctx->coded_height != s->height || @@ -1311,8 +1355,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { // MPEG-1 fps avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index]; -// MPEG-1 aspect -avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255); avctx->ticks_per_frame = 1; } else { // MPEG-2 // MPEG-2 fps @@ -1322,46 +1364,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 1 << 30); avctx->ticks_per_frame = 2; -// MPEG-2 aspect -if (s->aspect_ratio_info > 1) { -AVRational dar = -av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], - (AVRational) { s1->pan_scan.width, - s1->pan_scan.height }), - (AVRational) { s->width, s->height }); - -/* We ignore the spec here and guess a bit as reality does not - * match the spec, see for example res_change_ffmpeg_aspect.ts - * and sequence-display-aspect.mpg. - * issue1613, 621, 562 */ -if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) || -(av_cmp_q(dar, (AVRational) { 4, 3 }) && - av_cmp_q(dar, (AVRational) { 16, 9 }))) { -s->avctx->sample_aspect_ratio = -av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], - (AVRational) { s->width, s->height