mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 23:18:52 +00:00
ffdec: cleanups
Make things a little more readable.
This commit is contained in:
parent
3efd2bcbf7
commit
3a8445fc80
1 changed files with 52 additions and 51 deletions
|
@ -1128,16 +1128,14 @@ gst_ffmpegdec_bufferpool (GstFFMpegDec * ffmpegdec)
|
||||||
gint linesize_align[4];
|
gint linesize_align[4];
|
||||||
guint edge;
|
guint edge;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
AVCodecContext *context = ffmpegdec->context;
|
||||||
|
|
||||||
width = ffmpegdec->ctx_width;
|
width = ffmpegdec->ctx_width;
|
||||||
height = ffmpegdec->ctx_height;
|
height = ffmpegdec->ctx_height;
|
||||||
|
|
||||||
/* let ffmpeg find the alignment and padding */
|
/* let ffmpeg find the alignment and padding */
|
||||||
avcodec_align_dimensions2 (ffmpegdec->context, &width, &height,
|
avcodec_align_dimensions2 (context, &width, &height, linesize_align);
|
||||||
linesize_align);
|
edge = context->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width ();
|
||||||
edge =
|
|
||||||
ffmpegdec->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;
|
||||||
|
@ -1193,14 +1191,16 @@ gst_ffmpegdec_bufferpool (GstFFMpegDec * ffmpegdec)
|
||||||
static gboolean
|
static gboolean
|
||||||
update_video_context (GstFFMpegDec * ffmpegdec, gboolean force)
|
update_video_context (GstFFMpegDec * ffmpegdec, gboolean force)
|
||||||
{
|
{
|
||||||
if (!force && ffmpegdec->ctx_width == ffmpegdec->context->width
|
AVCodecContext *context = ffmpegdec->context;
|
||||||
&& ffmpegdec->ctx_height == ffmpegdec->context->height
|
|
||||||
&& ffmpegdec->ctx_ticks == ffmpegdec->context->ticks_per_frame
|
if (!force && ffmpegdec->ctx_width == context->width
|
||||||
&& ffmpegdec->ctx_time_n == ffmpegdec->context->time_base.num
|
&& ffmpegdec->ctx_height == context->height
|
||||||
&& ffmpegdec->ctx_time_d == ffmpegdec->context->time_base.den
|
&& ffmpegdec->ctx_ticks == context->ticks_per_frame
|
||||||
&& ffmpegdec->ctx_pix_fmt == ffmpegdec->context->pix_fmt
|
&& ffmpegdec->ctx_time_n == context->time_base.num
|
||||||
&& ffmpegdec->ctx_par_n == ffmpegdec->context->sample_aspect_ratio.num
|
&& ffmpegdec->ctx_time_d == context->time_base.den
|
||||||
&& ffmpegdec->ctx_par_d == ffmpegdec->context->sample_aspect_ratio.den)
|
&& ffmpegdec->ctx_pix_fmt == context->pix_fmt
|
||||||
|
&& ffmpegdec->ctx_par_n == context->sample_aspect_ratio.num
|
||||||
|
&& ffmpegdec->ctx_par_d == context->sample_aspect_ratio.den)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ffmpegdec,
|
GST_DEBUG_OBJECT (ffmpegdec,
|
||||||
|
@ -1208,45 +1208,19 @@ update_video_context (GstFFMpegDec * ffmpegdec, gboolean force)
|
||||||
ffmpegdec->ctx_width, ffmpegdec->ctx_height,
|
ffmpegdec->ctx_width, ffmpegdec->ctx_height,
|
||||||
ffmpegdec->ctx_par_n, ffmpegdec->ctx_par_d,
|
ffmpegdec->ctx_par_n, ffmpegdec->ctx_par_d,
|
||||||
ffmpegdec->ctx_time_n, ffmpegdec->ctx_time_d,
|
ffmpegdec->ctx_time_n, ffmpegdec->ctx_time_d,
|
||||||
ffmpegdec->context->width, ffmpegdec->context->height,
|
context->width, context->height,
|
||||||
ffmpegdec->context->sample_aspect_ratio.num,
|
context->sample_aspect_ratio.num,
|
||||||
ffmpegdec->context->sample_aspect_ratio.den,
|
context->sample_aspect_ratio.den,
|
||||||
ffmpegdec->context->time_base.num, ffmpegdec->context->time_base.den);
|
context->time_base.num, context->time_base.den);
|
||||||
|
|
||||||
ffmpegdec->ctx_width = ffmpegdec->context->width;
|
ffmpegdec->ctx_width = context->width;
|
||||||
ffmpegdec->ctx_height = ffmpegdec->context->height;
|
ffmpegdec->ctx_height = context->height;
|
||||||
ffmpegdec->ctx_ticks = ffmpegdec->context->ticks_per_frame;
|
ffmpegdec->ctx_ticks = context->ticks_per_frame;
|
||||||
ffmpegdec->ctx_time_n = ffmpegdec->context->time_base.num;
|
ffmpegdec->ctx_time_n = context->time_base.num;
|
||||||
ffmpegdec->ctx_time_d = ffmpegdec->context->time_base.den;
|
ffmpegdec->ctx_time_d = context->time_base.den;
|
||||||
ffmpegdec->ctx_pix_fmt = ffmpegdec->context->pix_fmt;
|
ffmpegdec->ctx_pix_fmt = context->pix_fmt;
|
||||||
ffmpegdec->ctx_par_n = ffmpegdec->context->sample_aspect_ratio.num;
|
ffmpegdec->ctx_par_n = context->sample_aspect_ratio.num;
|
||||||
ffmpegdec->ctx_par_d = ffmpegdec->context->sample_aspect_ratio.den;
|
ffmpegdec->ctx_par_d = context->sample_aspect_ratio.den;
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
update_audio_context (GstFFMpegDec * ffmpegdec, gboolean force)
|
|
||||||
{
|
|
||||||
gint depth;
|
|
||||||
|
|
||||||
depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
|
|
||||||
|
|
||||||
if (!force && ffmpegdec->format.audio.samplerate ==
|
|
||||||
ffmpegdec->context->sample_rate &&
|
|
||||||
ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
|
|
||||||
ffmpegdec->format.audio.depth == depth)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ffmpegdec,
|
|
||||||
"Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
|
|
||||||
ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
|
|
||||||
ffmpegdec->format.audio.depth,
|
|
||||||
ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
|
|
||||||
|
|
||||||
ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
|
|
||||||
ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
|
|
||||||
ffmpegdec->format.audio.depth = depth;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1379,6 +1353,33 @@ no_bufferpool:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_audio_context (GstFFMpegDec * ffmpegdec, gboolean force)
|
||||||
|
{
|
||||||
|
AVCodecContext *context = ffmpegdec->context;
|
||||||
|
gint depth;
|
||||||
|
|
||||||
|
depth = av_smp_format_depth (context->sample_fmt);
|
||||||
|
|
||||||
|
if (!force && ffmpegdec->format.audio.samplerate ==
|
||||||
|
context->sample_rate &&
|
||||||
|
ffmpegdec->format.audio.channels == context->channels &&
|
||||||
|
ffmpegdec->format.audio.depth == depth)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec,
|
||||||
|
"Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
|
||||||
|
ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
|
||||||
|
ffmpegdec->format.audio.depth,
|
||||||
|
context->sample_rate, context->channels, depth);
|
||||||
|
|
||||||
|
ffmpegdec->format.audio.samplerate = context->sample_rate;
|
||||||
|
ffmpegdec->format.audio.channels = context->channels;
|
||||||
|
ffmpegdec->format.audio.depth = depth;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_ffmpegdec_audio_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
|
gst_ffmpegdec_audio_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue