From 9367c8ea5839d000875b1c92aa645badd592d5e6 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 8 Nov 2012 11:40:47 +0200 Subject: [PATCH] mpeg2: fix PAR calculation from commit bd11bae. Invoke gst_mpeg_video_finalise_mpeg2_sequence_header() to get the correct PAR values. While doing so, require a newer version of the bitstream parser library. Note: it may be necessary to also parse the Sequence_Display_Extension() header. Signed-off-by: Sreerenj Balachandran Signed-off-by: Gwenole Beauchesne --- configure.ac | 24 ++++++++++++++++++++++++ gst-libs/gst/codecparsers/Makefile.am | 13 +++++++++---- gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c | 14 +++++++++----- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 20e193d..0a27282 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,30 @@ dnl ... bitstream parsers PKG_CHECK_MODULES([GST_CODEC_PARSERS], [gstreamer-codecparsers-$GST_MAJORMINOR >= gst_plugins_bad_version]) +dnl ... MPEG-2 parser, with the required extensions +AC_CACHE_CHECK([for MPEG-2 parser], + ac_cv_have_gst_mpeg2_parser, [ + saved_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $GST_CFLAGS $GST_CODEC_PARSERS_CFLAGS" + saved_LIBS="$LIBS" + LIBS="$LIBS $GST_LIBS $GST_CODEC_PARSERS_LIBS" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[GstMpegVideoSequenceHdr seq_hdr; + GstMpegVideoSequenceExt seq_ext; + GstMpegVideoSequenceDisplayExt seq_dpy; + gst_mpeg_video_finalise_mpeg2_sequence_header(&seq_hdr, + &seq_ext, &seq_dpy);]])], + [ac_cv_have_gst_mpeg2_parser="yes"], + [ac_cv_have_gst_mpeg2_parser="no"] + ) + CPPFLAGS="$saved_CPPFLAGS" + LIBS="$saved_LIBS" +]) +AM_CONDITIONAL([USE_LOCAL_CODEC_PARSERS_MPEG2], + [test "$ac_cv_have_gst_mpeg2_parser" != "yes"]) + dnl ... H.264 parser, with the required extensions AC_CACHE_CHECK([for H.264 parser], ac_cv_have_gst_h264_parser, [ diff --git a/gst-libs/gst/codecparsers/Makefile.am b/gst-libs/gst/codecparsers/Makefile.am index 4f226cb..46851c0 100644 --- a/gst-libs/gst/codecparsers/Makefile.am +++ b/gst-libs/gst/codecparsers/Makefile.am @@ -17,17 +17,22 @@ libgstvaapi_codecparsers_libs = \ $(GST_LIBS) \ $(NULL) -gen_source_c = -gen_source_h = +gen_source_c = parserutils.c +gen_source_h = parserutils.h if USE_LOCAL_CODEC_PARSERS_JPEG gen_source_c += gstjpegparser.c gen_source_h += gstjpegparser.h endif +if USE_LOCAL_CODEC_PARSERS_MPEG2 +gen_source_c += gstmpegvideoparser.c +gen_source_h += gstmpegvideoparser.h +endif + if USE_LOCAL_CODEC_PARSERS_H264 -gen_source_c += gsth264parser.c parserutils.c -gen_source_h += gsth264parser.h parserutils.h +gen_source_c += gsth264parser.c +gen_source_h += gsth264parser.h endif GENFILES = \ diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c index 7b47905..8bdb13f 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c @@ -519,11 +519,9 @@ decode_sequence(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size) pts_set_framerate(&priv->tsg, priv->fps_n, priv->fps_d); gst_vaapi_decoder_set_framerate(base_decoder, priv->fps_n, priv->fps_d); - gst_vaapi_decoder_set_pixel_aspect_ratio( - base_decoder, - seq_hdr->par_w, - seq_hdr->par_h - ); + if (gst_mpeg_video_finalise_mpeg2_sequence_header(seq_hdr, NULL, NULL)) + gst_vaapi_decoder_set_pixel_aspect_ratio(base_decoder, + seq_hdr->par_w, seq_hdr->par_h); priv->width = seq_hdr->width; priv->height = seq_hdr->height; @@ -539,6 +537,7 @@ decode_sequence_ext(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size) { GstVaapiDecoder * const base_decoder = GST_VAAPI_DECODER(decoder); GstVaapiDecoderMpeg2Private * const priv = decoder->priv; + GstMpegVideoSequenceHdr * const seq_hdr = &priv->seq_hdr; GstMpegVideoSequenceExt * const seq_ext = &priv->seq_ext; GstVaapiProfile profile; guint width, height; @@ -590,6 +589,11 @@ decode_sequence_ext(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size) priv->profile = profile; priv->profile_changed = TRUE; } + + if (gst_mpeg_video_finalise_mpeg2_sequence_header(seq_hdr, seq_ext, NULL)) + gst_vaapi_decoder_set_pixel_aspect_ratio(base_decoder, + seq_hdr->par_w, seq_hdr->par_h); + return GST_VAAPI_DECODER_STATUS_SUCCESS; } -- 2.7.4