if (!pos)
return 0;
+ if (channels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_MONO)
+ return AV_CH_LAYOUT_MONO;
+
for (i = 0; i < channels; i++) {
for (j = 0; j < G_N_ELEMENTS (_ff_to_gst_layout); j++) {
if (_ff_to_gst_layout[j].gst == pos[i]) {
} else {
guint i, j;
+ /* Special path for mono, as AV_CH_LAYOUT_MONO is the same
+ * as FRONT_CENTER but we distinguish between the two in
+ * GStreamer
+ */
+ if (channels == 1 && channel_layout == AV_CH_LAYOUT_MONO) {
+ pos[0] = GST_AUDIO_CHANNEL_POSITION_MONO;
+ return TRUE;
+ }
+
for (i = 0; i < 64; i++) {
if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
nchannels++;
}
break;
- case AV_CODEC_ID_MPEG2VIDEO_XVMC:
- /* this is a special ID - don't need it in GStreamer, I think */
- break;
-
case AV_CODEC_ID_H263:
if (encode) {
caps =
"parsed", G_TYPE_BOOLEAN, TRUE, NULL);
break;
+ case AV_CODEC_ID_JPEG2000:
+ caps =
+ gst_ff_vid_caps_new (context, NULL, codec_id, encode, "image/x-j2c",
+ NULL);
+ if (!encode) {
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, NULL, codec_id,
+ encode, "image/x-jpc", NULL));
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, NULL, codec_id,
+ encode, "image/jp2", NULL));
+ }
+ break;
+
case AV_CODEC_ID_SP5X:
caps =
gst_ff_vid_caps_new (context, NULL, codec_id, encode, "video/sp5x",
caps =
gst_ff_aud_caps_new (context, NULL, codec_id, encode, "audio/x-wma",
"wmaversion", G_TYPE_INT, version, "block_align", G_TYPE_INT,
- context->block_align, "bitrate", G_TYPE_INT, context->bit_rate,
- NULL);
+ context->block_align, "bitrate", G_TYPE_INT,
+ (guint) context->bit_rate, NULL);
} else {
caps =
gst_ff_aud_caps_new (context, NULL, codec_id, encode, "audio/x-wma",
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
break;
case AV_CODEC_ID_ADPCM_G726:
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
if (!encode) {
gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
}
break;
if (context) {
gst_caps_set_simple (caps,
"leaf_size", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
}
}
break;
if (context) {
gst_caps_set_simple (caps,
"leaf_size", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
}
}
break;
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
}
break;
}
break;
+ case AV_CODEC_ID_OPUS:
+ /* Note that ffmpeg has no encoder yet, but just for safety. In the
+ * encoder case, we want to add things like samplerate, channels... */
+ if (!encode) {
+ /* FIXME: can ffmpeg handle multichannel Opus? */
+ caps = gst_caps_new_simple ("audio/x-opus",
+ "channel-mapping-family", G_TYPE_INT, 0, NULL);
+ }
+ break;
+
case AV_CODEC_ID_S302M:
caps = gst_caps_new_empty_simple ("audio/x-smpte-302m");
break;
gst_ff_aud_caps_new (context, NULL, codec_id, encode,
"audio/x-twin-vq", NULL);
break;
+ case AV_CODEC_ID_G729:
+ caps =
+ gst_ff_aud_caps_new (context, NULL, codec_id, encode, "audio/G729",
+ NULL);
+ break;
default:
GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
break;
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
- "bitrate", G_TYPE_INT, context->bit_rate, NULL);
+ "bitrate", G_TYPE_INT, (guint) context->bit_rate, NULL);
g_free (mime);
break;
default:
*/
static GstCaps *
-gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
+gst_ffmpeg_pixfmt_to_caps (enum AVPixelFormat pix_fmt, AVCodecContext * context,
enum AVCodecID codec_id)
{
GstCaps *caps = NULL;
GstStructure *structure;
const gchar *fmt;
GstAudioFormat format = GST_AUDIO_FORMAT_UNKNOWN;
+ gint bitrate;
g_return_if_fail (gst_caps_get_size (caps) == 1);
gst_structure_get_int (structure, "channels", &context->channels);
gst_structure_get_int (structure, "rate", &context->sample_rate);
gst_structure_get_int (structure, "block_align", &context->block_align);
- gst_structure_get_int (structure, "bitrate", &context->bit_rate);
+ if (gst_structure_get_int (structure, "bitrate", &bitrate))
+ context->bit_rate = bitrate;
if (!raw)
return;
context->time_base.den, context->time_base.num,
1. * context->time_base.den / context->time_base.num);
} else {
- GST_WARNING ("ignoring insane framerate %d/%d",
- context->time_base.den, context->time_base.num);
+ GST_INFO ("ignoring framerate %d/%d (probably variable framerate)",
+ context->time_base.num, context->time_base.den);
}
}
typedef struct
{
GstVideoFormat format;
- enum PixelFormat pixfmt;
+ enum AVPixelFormat pixfmt;
} PixToFmt;
/* FIXME : FILLME */
};
GstVideoFormat
-gst_ffmpeg_pixfmt_to_videoformat (enum PixelFormat pixfmt)
+gst_ffmpeg_pixfmt_to_videoformat (enum AVPixelFormat pixfmt)
{
guint i;
return GST_VIDEO_FORMAT_UNKNOWN;
}
-static enum PixelFormat
+static enum AVPixelFormat
gst_ffmpeg_videoformat_to_pixfmt_for_codec (GstVideoFormat format,
const AVCodec * codec)
{
return AV_PIX_FMT_NONE;
}
-enum PixelFormat
+enum AVPixelFormat
gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format)
{
return gst_ffmpeg_videoformat_to_pixfmt_for_codec (format, NULL);
context->pix_fmt =
gst_ffmpeg_videoformat_to_pixfmt_for_codec (GST_VIDEO_INFO_FORMAT (info),
context->codec);
+
+ switch (info->chroma_site) {
+ case GST_VIDEO_CHROMA_SITE_MPEG2:
+ context->chroma_sample_location = AVCHROMA_LOC_LEFT;
+ break;
+ case GST_VIDEO_CHROMA_SITE_JPEG:
+ context->chroma_sample_location = AVCHROMA_LOC_CENTER;
+ break;
+ case GST_VIDEO_CHROMA_SITE_DV:
+ context->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
+ break;
+ case GST_VIDEO_CHROMA_SITE_V_COSITED:
+ context->chroma_sample_location = AVCHROMA_LOC_TOP;
+ break;
+ default:
+ break;
+ }
+
+ switch (info->colorimetry.primaries) {
+ case GST_VIDEO_COLOR_PRIMARIES_BT709:
+ context->color_primaries = AVCOL_PRI_BT709;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_BT470M:
+ context->color_primaries = AVCOL_PRI_BT470M;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_BT470BG:
+ context->color_primaries = AVCOL_PRI_BT470BG;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
+ context->color_primaries = AVCOL_PRI_SMPTE170M;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
+ context->color_primaries = AVCOL_PRI_SMPTE240M;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_FILM:
+ context->color_primaries = AVCOL_PRI_FILM;
+ break;
+ case GST_VIDEO_COLOR_PRIMARIES_BT2020:
+ context->color_primaries = AVCOL_PRI_BT2020;
+ break;
+ default:
+ break;
+ }
+
+ switch (info->colorimetry.transfer) {
+ case GST_VIDEO_TRANSFER_BT709:
+ context->color_trc = AVCOL_TRC_BT709;
+ break;
+ case GST_VIDEO_TRANSFER_GAMMA22:
+ context->color_trc = AVCOL_TRC_GAMMA22;
+ break;
+ case GST_VIDEO_TRANSFER_GAMMA28:
+ context->color_trc = AVCOL_TRC_GAMMA28;
+ break;
+ case GST_VIDEO_TRANSFER_SMPTE240M:
+ context->color_trc = AVCOL_TRC_SMPTE240M;
+ break;
+ case GST_VIDEO_TRANSFER_GAMMA10:
+ context->color_trc = AVCOL_TRC_LINEAR;
+ break;
+ case GST_VIDEO_TRANSFER_LOG100:
+ context->color_trc = AVCOL_TRC_LOG;
+ break;
+ case GST_VIDEO_TRANSFER_LOG316:
+ context->color_trc = AVCOL_TRC_LOG_SQRT;
+ break;
+ case GST_VIDEO_TRANSFER_BT2020_12:
+ context->color_trc = AVCOL_TRC_BT2020_12;
+ break;
+ default:
+ break;
+ }
+
+ switch (info->colorimetry.matrix) {
+ case GST_VIDEO_COLOR_MATRIX_RGB:
+ context->colorspace = AVCOL_SPC_RGB;
+ break;
+ case GST_VIDEO_COLOR_MATRIX_BT709:
+ context->colorspace = AVCOL_SPC_BT709;
+ break;
+ case GST_VIDEO_COLOR_MATRIX_FCC:
+ context->colorspace = AVCOL_SPC_FCC;
+ break;
+ case GST_VIDEO_COLOR_MATRIX_BT601:
+ context->colorspace = AVCOL_SPC_BT470BG;
+ break;
+ case GST_VIDEO_COLOR_MATRIX_SMPTE240M:
+ context->colorspace = AVCOL_SPC_SMPTE240M;
+ break;
+ case GST_VIDEO_COLOR_MATRIX_BT2020:
+ context->colorspace = AVCOL_SPC_BT2020_NCL;
+ break;
+ default:
+ break;
+ }
+
+ if (info->colorimetry.range == GST_VIDEO_COLOR_RANGE_0_255) {
+ context->color_range = AVCOL_RANGE_JPEG;
+ } else {
+ context->color_range = AVCOL_RANGE_MPEG;
+ }
}
void
GST_DEBUG ("have codec data of size %" G_GSIZE_FORMAT, map.size);
gst_buffer_unmap (buf, &map);
- } else if (context->extradata == NULL && codec_id != AV_CODEC_ID_AAC_LATM &&
- codec_id != AV_CODEC_ID_FLAC) {
- /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
- * extradata anyway which makes then segfault. */
- context->extradata =
- av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
+ } else {
+ context->extradata = NULL;
context->extradata_size = 0;
GST_DEBUG ("no codec data");
}
"y4mversion", G_TYPE_INT, 2, NULL);
} else if (!strcmp (format_name, "mpc")) {
caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
+ } else if (!strcmp (format_name, "mpc8")) {
+ caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 8");
} else if (!strcmp (format_name, "vqf")) {
caps = gst_caps_from_string ("audio/x-vqf");
} else if (!strcmp (format_name, "nsv")) {