mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
avidemux: append palette data to paletted 8-bit RGB frames
Fixes playback of 8-bit indexed RGB videos, with fixes in -base. https://bugzilla.gnome.org/show_bug.cgi?id=686046
This commit is contained in:
parent
7ceef442a7
commit
f94572fb36
2 changed files with 25 additions and 8 deletions
|
@ -223,6 +223,8 @@ gst_avi_demux_reset_stream (GstAviDemux * avi, GstAviStream * stream)
|
|||
gst_buffer_unref (stream->initdata);
|
||||
if (stream->extradata)
|
||||
gst_buffer_unref (stream->extradata);
|
||||
if (stream->rgb8_palette)
|
||||
gst_buffer_unref (stream->rgb8_palette);
|
||||
if (stream->pad) {
|
||||
if (stream->exposed) {
|
||||
gst_pad_set_active (stream->pad, FALSE);
|
||||
|
@ -1896,15 +1898,24 @@ gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
|
|||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_avi_demux_check_caps (GstAviDemux * avi, GstCaps * caps)
|
||||
gst_avi_demux_check_caps (GstAviDemux * avi, GstCaps * caps,
|
||||
GstBuffer ** rgb8_palette)
|
||||
{
|
||||
GstStructure *s;
|
||||
const GValue *val;
|
||||
GstBuffer *buf;
|
||||
|
||||
caps = gst_caps_make_writable (caps);
|
||||
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
if (!gst_structure_has_name (s, "video/x-h264"))
|
||||
if (gst_structure_has_name (s, "video/x-raw") &&
|
||||
gst_structure_has_field_typed (s, "palette_data", GST_TYPE_BUFFER)) {
|
||||
gst_structure_get (s, "palette_data", GST_TYPE_BUFFER, rgb8_palette, NULL);
|
||||
gst_structure_remove_field (s, "palette_data");
|
||||
return caps;
|
||||
} else if (!gst_structure_has_name (s, "video/x-h264")) {
|
||||
return caps;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (avi, "checking caps %" GST_PTR_FORMAT, caps);
|
||||
|
||||
|
@ -2243,7 +2254,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
|
|||
g_free (vprp);
|
||||
vprp = NULL;
|
||||
}
|
||||
caps = gst_avi_demux_check_caps (avi, caps);
|
||||
caps = gst_avi_demux_check_caps (avi, caps, &stream->rgb8_palette);
|
||||
tag_name = GST_TAG_VIDEO_CODEC;
|
||||
avi->num_v_streams++;
|
||||
break;
|
||||
|
@ -2296,8 +2307,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (element, "codec-name=%s",
|
||||
(codec_name ? codec_name : "NULL"));
|
||||
GST_DEBUG_OBJECT (element, "codec-name=%s", codec_name ? codec_name : "NULL");
|
||||
GST_DEBUG_OBJECT (element, "caps=%" GST_PTR_FORMAT, caps);
|
||||
|
||||
/* set proper settings and add it */
|
||||
|
@ -4531,7 +4541,9 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
|
|||
s = gst_caps_get_structure (caps, 0);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
if (!gst_structure_get_int (s, "bpp", &bpp)) {
|
||||
if (stream->rgb8_palette != NULL) {
|
||||
bpp = 8;
|
||||
} else if (!gst_structure_get_int (s, "bpp", &bpp)) { /* FIXME */
|
||||
GST_WARNING ("Failed to retrieve depth from caps");
|
||||
return buf;
|
||||
}
|
||||
|
@ -4560,6 +4572,10 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
|
|||
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
/* append palette to paletted RGB8 buffer data */
|
||||
if (stream->rgb8_palette != NULL)
|
||||
buf = gst_buffer_append (buf, gst_buffer_ref (stream->rgb8_palette));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -4819,7 +4835,7 @@ gst_avi_demux_loop_data (GstAviDemux * avi)
|
|||
if (gst_buffer_get_size (buf) < size)
|
||||
goto short_buffer;
|
||||
|
||||
/* invert the picture if needed */
|
||||
/* invert the picture if needed, and append palette for RGB8P */
|
||||
buf = gst_avi_demux_invert (stream, buf);
|
||||
|
||||
/* mark non-keyframes */
|
||||
|
@ -5100,7 +5116,7 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
|
|||
if (saw_desired_kf && buf) {
|
||||
GstClockTime dur_ts = 0;
|
||||
|
||||
/* invert the picture if needed */
|
||||
/* invert the picture if needed, and append palette for RGB8P */
|
||||
buf = gst_avi_demux_invert (stream, buf);
|
||||
|
||||
gst_pad_query_position (stream->pad, GST_FORMAT_TIME,
|
||||
|
|
|
@ -73,6 +73,7 @@ typedef struct {
|
|||
gpointer data;
|
||||
} strf;
|
||||
GstBuffer *extradata, *initdata;
|
||||
GstBuffer *rgb8_palette;
|
||||
gchar *name;
|
||||
|
||||
/* the start/step/stop entries */
|
||||
|
|
Loading…
Reference in a new issue