mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
ffmpegcolorspace: Include interlacing information in the AVPicture
This later allows to handle interlaced AVPicture different than progressive ones which is needed for horizontally subsampled YUV formats, see bug #589242.
This commit is contained in:
parent
33c490f4b9
commit
164b90f9d0
6 changed files with 22 additions and 8 deletions
|
@ -190,6 +190,7 @@ typedef struct AVCodecContext {
|
|||
typedef struct AVPicture {
|
||||
uint8_t *data[4];
|
||||
int linesize[4]; ///< number of bytes per line
|
||||
int interlaced;
|
||||
} AVPicture;
|
||||
|
||||
/**
|
||||
|
|
|
@ -801,7 +801,8 @@ gst_ffmpegcsp_caps_with_codectype (enum CodecType type,
|
|||
*/
|
||||
int
|
||||
gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
|
||||
uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
|
||||
uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height,
|
||||
int interlaced)
|
||||
{
|
||||
int size, w2, h2, size2;
|
||||
int stride, stride2;
|
||||
|
@ -809,6 +810,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
|
|||
|
||||
pinfo = get_pix_fmt_info (pix_fmt);
|
||||
|
||||
picture->interlaced = interlaced;
|
||||
|
||||
switch (pix_fmt) {
|
||||
case PIX_FMT_YUV420P:
|
||||
case PIX_FMT_YUV422P:
|
||||
|
|
|
@ -51,7 +51,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
|
|||
uint8_t * ptr,
|
||||
enum PixelFormat pix_fmt,
|
||||
int width,
|
||||
int height);
|
||||
int height,
|
||||
int interlaced);
|
||||
|
||||
#endif /* __GST_FFMPEG_CODECMAP_H__ */
|
||||
|
||||
|
|
|
@ -219,6 +219,9 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
|||
space->width = ctx->width = in_width;
|
||||
space->height = ctx->height = in_height;
|
||||
|
||||
space->interlaced = FALSE;
|
||||
gst_structure_get_boolean (structure, "interlaced", &space->interlaced);
|
||||
|
||||
/* get from format */
|
||||
ctx->pix_fmt = PIX_FMT_NB;
|
||||
gst_ffmpegcsp_caps_with_codectype (CODEC_TYPE_VIDEO, incaps, ctx);
|
||||
|
@ -445,7 +448,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
|
|||
|
||||
/* fill from with source data */
|
||||
gst_ffmpegcsp_avpicture_fill (&space->from_frame,
|
||||
GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height);
|
||||
GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height,
|
||||
space->interlaced);
|
||||
|
||||
/* fill optional palette */
|
||||
if (space->palette)
|
||||
|
@ -453,7 +457,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
|
|||
|
||||
/* fill target frame */
|
||||
gst_ffmpegcsp_avpicture_fill (&space->to_frame,
|
||||
GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height);
|
||||
GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height,
|
||||
space->interlaced);
|
||||
|
||||
/* and convert */
|
||||
result = img_convert (&space->to_frame, space->to_pixfmt,
|
||||
|
|
|
@ -46,6 +46,7 @@ struct _GstFFMpegCsp {
|
|||
GstBaseTransform element;
|
||||
|
||||
gint width, height;
|
||||
gboolean interlaced;
|
||||
gfloat fps;
|
||||
enum PixelFormat from_pixfmt, to_pixfmt;
|
||||
AVPicture from_frame, to_frame;
|
||||
|
|
|
@ -565,7 +565,7 @@ avpicture_get_size (int pix_fmt, int width, int height)
|
|||
AVPicture dummy_pict;
|
||||
|
||||
return gst_ffmpegcsp_avpicture_fill (&dummy_pict, NULL, pix_fmt, width,
|
||||
height);
|
||||
height, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2908,7 +2908,8 @@ get_convert_table_entry (int src_pix_fmt, int dst_pix_fmt)
|
|||
}
|
||||
|
||||
static int
|
||||
avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height)
|
||||
avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height,
|
||||
int interlaced)
|
||||
{
|
||||
unsigned int size;
|
||||
void *ptr;
|
||||
|
@ -2917,7 +2918,8 @@ avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height)
|
|||
ptr = av_malloc (size);
|
||||
if (!ptr)
|
||||
goto fail;
|
||||
gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height);
|
||||
gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height,
|
||||
interlaced);
|
||||
return 0;
|
||||
fail:
|
||||
memset (picture, 0, sizeof (AVPicture));
|
||||
|
@ -3159,7 +3161,8 @@ no_chroma_filter:
|
|||
else
|
||||
int_pix_fmt = PIX_FMT_RGB24;
|
||||
}
|
||||
if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height) < 0)
|
||||
if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height,
|
||||
dst->interlaced) < 0)
|
||||
return -1;
|
||||
ret = -1;
|
||||
if (img_convert (tmp, int_pix_fmt,
|
||||
|
|
Loading…
Reference in a new issue