mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
libav: fix palette support again
This commit is contained in:
parent
736bda7350
commit
4c46f11d5f
2 changed files with 35 additions and 2 deletions
|
@ -287,6 +287,8 @@ gst_ffmpegviddec_close (GstFFMpegVidDec * ffmpegdec)
|
||||||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||||
ffmpegdec->opened = FALSE;
|
ffmpegdec->opened = FALSE;
|
||||||
|
|
||||||
|
gst_buffer_replace (&ffmpegdec->palette, NULL);
|
||||||
|
|
||||||
if (ffmpegdec->context->extradata) {
|
if (ffmpegdec->context->extradata) {
|
||||||
av_free (ffmpegdec->context->extradata);
|
av_free (ffmpegdec->context->extradata);
|
||||||
ffmpegdec->context->extradata = NULL;
|
ffmpegdec->context->extradata = NULL;
|
||||||
|
@ -334,6 +336,25 @@ could_not_open:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_ffmpegviddec_get_palette (GstFFMpegVidDec * ffmpegdec,
|
||||||
|
GstVideoCodecState * state)
|
||||||
|
{
|
||||||
|
GstStructure *str = gst_caps_get_structure (state->caps, 0);
|
||||||
|
const GValue *palette_v;
|
||||||
|
GstBuffer *palette;
|
||||||
|
|
||||||
|
/* do we have a palette? */
|
||||||
|
if ((palette_v = gst_structure_get_value (str, "palette_data"))) {
|
||||||
|
palette = gst_value_get_buffer (palette_v);
|
||||||
|
GST_DEBUG ("got palette data %p", palette);
|
||||||
|
if (gst_buffer_get_size (palette) >= AVPALETTE_SIZE) {
|
||||||
|
gst_buffer_replace (&ffmpegdec->palette, palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_ffmpegviddec_set_format (GstVideoDecoder * decoder,
|
gst_ffmpegviddec_set_format (GstVideoDecoder * decoder,
|
||||||
GstVideoCodecState * state)
|
GstVideoCodecState * state)
|
||||||
|
@ -389,6 +410,8 @@ gst_ffmpegviddec_set_format (GstVideoDecoder * decoder,
|
||||||
GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
|
GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
|
||||||
ffmpegdec->context->height);
|
ffmpegdec->context->height);
|
||||||
|
|
||||||
|
gst_ffmpegviddec_get_palette (ffmpegdec, state);
|
||||||
|
|
||||||
if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
|
if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
|
||||||
GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
|
GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
|
||||||
ffmpegdec->context->time_base.num = 1;
|
ffmpegdec->context->time_base.num = 1;
|
||||||
|
@ -1061,6 +1084,15 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec,
|
||||||
/* now decode the frame */
|
/* now decode the frame */
|
||||||
gst_avpacket_init (&packet, data, size);
|
gst_avpacket_init (&packet, data, size);
|
||||||
|
|
||||||
|
if (ffmpegdec->palette) {
|
||||||
|
guint8 *pal;
|
||||||
|
|
||||||
|
pal = av_packet_new_side_data (&packet, AV_PKT_DATA_PALETTE,
|
||||||
|
AVPALETTE_SIZE);
|
||||||
|
gst_buffer_extract (ffmpegdec->palette, 0, pal, AVPALETTE_SIZE);
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec, "copy pal %p %p", &packet, pal);
|
||||||
|
}
|
||||||
|
|
||||||
len = avcodec_decode_video2 (ffmpegdec->context,
|
len = avcodec_decode_video2 (ffmpegdec->context,
|
||||||
ffmpegdec->picture, &have_data, &packet);
|
ffmpegdec->picture, &have_data, &packet);
|
||||||
|
|
||||||
|
@ -1456,8 +1488,8 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
||||||
avcodec_align_dimensions2 (ffmpegdec->context, &width, &height,
|
avcodec_align_dimensions2 (ffmpegdec->context, &width, &height,
|
||||||
linesize_align);
|
linesize_align);
|
||||||
edge =
|
edge =
|
||||||
ffmpegdec->context->
|
ffmpegdec->
|
||||||
flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width ();
|
context->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width ();
|
||||||
/* increase the size for the padding */
|
/* increase the size for the padding */
|
||||||
width += edge << 1;
|
width += edge << 1;
|
||||||
height += edge << 1;
|
height += edge << 1;
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct _GstFFMpegVidDec
|
||||||
gint ctx_time_d;
|
gint ctx_time_d;
|
||||||
gint ctx_time_n;
|
gint ctx_time_n;
|
||||||
gint ctx_interlaced;
|
gint ctx_interlaced;
|
||||||
|
GstBuffer *palette;
|
||||||
|
|
||||||
guint8 *padded;
|
guint8 *padded;
|
||||||
guint padded_size;
|
guint padded_size;
|
||||||
|
|
Loading…
Reference in a new issue