From 29d0c5bdd8beeb2b1ed25e8bf37eec9a135c5422 Mon Sep 17 00:00:00 2001 From: Carl-Anton Ingmarsson Date: Fri, 27 Mar 2009 16:55:19 +0100 Subject: vdpau: extract mpeg2 profile from codec_data --- sys/vdpau/gstvdpaumpegdecoder.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'sys/vdpau/gstvdpaumpegdecoder.c') diff --git a/sys/vdpau/gstvdpaumpegdecoder.c b/sys/vdpau/gstvdpaumpegdecoder.c index 380cf602..e5da459f 100644 --- a/sys/vdpau/gstvdpaumpegdecoder.c +++ b/sys/vdpau/gstvdpaumpegdecoder.c @@ -1,7 +1,5 @@ /* * GStreamer - * Copyright (C) 2005 Thomas Vander Stichele - * Copyright (C) 2005 Ronald S. Bultje * Copyright (C) 2009 Carl-Anton Ingmarsson * * Permission is hereby granted, free of charge, to any person obtaining a @@ -62,6 +60,7 @@ #include +#include "mpegutil.h" #include "gstvdpaumpegdecoder.h" GST_DEBUG_CATEGORY_STATIC (gst_vdpau_mpeg_decoder_debug); @@ -88,7 +87,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("video/mpeg, mpegversion = (int) [ 1, 2 ], " - "systemstream = (boolean) false") + "systemstream = (boolean) false, parsed = (boolean) true") ); GST_BOILERPLATE (GstVdpauMpegDecoder, gst_vdpau_mpeg_decoder, GstVdpauDecoder, @@ -104,11 +103,33 @@ gst_vdpau_mpeg_decoder_set_caps (GstVdpauDecoder * dec, GstCaps * caps) { GstVdpauMpegDecoder *mpeg_dec; GstStructure *structure; + gint version; mpeg_dec = GST_VDPAU_MPEG_DECODER (dec); structure = gst_caps_get_structure (caps, 0); - gst_structure_get_int (structure, "mpegversion", &mpeg_dec->version); + gst_structure_get_int (structure, "mpegversion", &version); + if (version == 1) + mpeg_dec->profile = VDP_DECODER_PROFILE_MPEG1; + + else { + const GValue *value; + GstBuffer *codec_data; + MPEGSeqHdr hdr = { 0, }; + + value = gst_structure_get_value (structure, "codec_data"); + codec_data = gst_value_get_buffer (value); + mpeg_util_parse_sequence_hdr (&hdr, GST_BUFFER_DATA (codec_data), + GST_BUFFER_DATA (codec_data) + GST_BUFFER_SIZE (codec_data)); + switch (hdr.profile) { + case 5: + mpeg_dec->profile = VDP_DECODER_PROFILE_MPEG2_SIMPLE; + break; + default: + mpeg_dec->profile = VDP_DECODER_PROFILE_MPEG2_MAIN; + break; + } + } return TRUE; } -- cgit v1.2.1