ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...

Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
This commit is contained in:
Ronald S. Bultje 2005-07-20 15:40:57 +00:00
parent 4fd68a7289
commit ada045509e
13 changed files with 138 additions and 101 deletions

View file

@ -1,3 +1,33 @@
2005-07-20 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-16 daniel fischer <dan@f3c.com> 2005-07-16 daniel fischer <dan@f3c.com>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>

2
common

@ -1 +1 @@
Subproject commit ac7272b7af934c2294a44ac1c0f3fac3f8d17ec6 Subproject commit 6f9b691adc2a0300598311671dd7c4d9d2035afa

View file

@ -44,6 +44,8 @@ extern gboolean gst_ffmpegdec_register (GstPlugin * plugin);
extern gboolean gst_ffmpegenc_register (GstPlugin * plugin); extern gboolean gst_ffmpegenc_register (GstPlugin * plugin);
extern gboolean gst_ffmpegmux_register (GstPlugin * plugin); extern gboolean gst_ffmpegmux_register (GstPlugin * plugin);
extern gboolean gst_ffmpegcsp_register (GstPlugin * plugin); extern gboolean gst_ffmpegcsp_register (GstPlugin * plugin);
extern gboolean gst_ffmpegscale_register (GstPlugin * plugin);
extern gboolean gst_ffmpegdeinterlace_register (GstPlugin * plugin);
G_END_DECLS G_END_DECLS

View file

@ -86,8 +86,9 @@ gst_ffmpeg_set_palette (GstCaps *caps, AVCodecContext *context)
gst_caps_new_simple (mimetype, \ gst_caps_new_simple (mimetype, \
"width", G_TYPE_INT, context->width, \ "width", G_TYPE_INT, context->width, \
"height", G_TYPE_INT, context->height, \ "height", G_TYPE_INT, context->height, \
"framerate", G_TYPE_DOUBLE, 1. * context->frame_rate / \ "framerate", G_TYPE_DOUBLE, 1. * \
context->frame_rate_base, \ context->time_base.den / \
context->time_base.num, \
__VA_ARGS__, NULL) \ __VA_ARGS__, NULL) \
: \ : \
gst_caps_new_simple (mimetype, \ gst_caps_new_simple (mimetype, \
@ -430,6 +431,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
"wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL); "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
break; break;
case CODEC_ID_FRAPS:
case CODEC_ID_VCR1: case CODEC_ID_VCR1:
case CODEC_ID_CLJR: case CODEC_ID_CLJR:
case CODEC_ID_MDEC: case CODEC_ID_MDEC:
@ -589,6 +591,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_ADPCM_G726: case CODEC_ID_ADPCM_G726:
case CODEC_ID_ADPCM_CT: case CODEC_ID_ADPCM_CT:
case CODEC_ID_ADPCM_SWF: case CODEC_ID_ADPCM_SWF:
case CODEC_ID_ADPCM_YAMAHA:
do { do {
gchar *layout = NULL; gchar *layout = NULL;
@ -635,6 +638,9 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_ADPCM_SWF: case CODEC_ID_ADPCM_SWF:
layout = "swf"; layout = "swf";
break; break;
case CODEC_ID_ADPCM_YAMAHA:
layout = "yamaha";
break;
default: default:
g_assert (0); /* don't worry, we never get here */ g_assert (0); /* don't worry, we never get here */
break; break;
@ -726,6 +732,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
} }
break; break;
case CODEC_ID_DVD_SUBTITLE:
case CODEC_ID_DVB_SUBTITLE:
caps = NULL;
break;
default: default:
g_warning ("Unknown codec ID %d, please add here", codec_id); g_warning ("Unknown codec ID %d, please add here", codec_id);
break; break;
@ -1089,8 +1100,8 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
gst_structure_get_int (structure, "bpp", &context->bits_per_sample); gst_structure_get_int (structure, "bpp", &context->bits_per_sample);
if (gst_structure_get_double (structure, "framerate", &fps)) { if (gst_structure_get_double (structure, "framerate", &fps)) {
context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE; context->time_base.den = fps * DEFAULT_FRAME_RATE_BASE;
context->frame_rate_base = DEFAULT_FRAME_RATE_BASE; context->time_base.num = DEFAULT_FRAME_RATE_BASE;
} }
if (!raw) if (!raw)
@ -1381,7 +1392,7 @@ gst_ffmpeg_formatid_get_codecids (const gchar *format_name,
enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list) enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list)
{ {
if (!strcmp (format_name, "mp4")) { if (!strcmp (format_name, "mp4")) {
static enum CodecID mp4_video_list[] = { CODEC_ID_MPEG4, CODEC_ID_NONE }; static enum CodecID mp4_video_list[] = { CODEC_ID_MPEG4, CODEC_ID_H264, CODEC_ID_NONE };
static enum CodecID mp4_audio_list[] = { CODEC_ID_AAC, CODEC_ID_NONE }; static enum CodecID mp4_audio_list[] = { CODEC_ID_AAC, CODEC_ID_NONE };
*video_codec_list = mp4_video_list; *video_codec_list = mp4_video_list;
@ -1392,6 +1403,12 @@ gst_ffmpeg_formatid_get_codecids (const gchar *format_name,
*video_codec_list = mpeg_video_list; *video_codec_list = mpeg_video_list;
*audio_codec_list = mpeg_audio_list; *audio_codec_list = mpeg_audio_list;
} else if (!strcmp (format_name, "vob")) {
static enum CodecID vob_video_list[] = { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3, CODEC_ID_NONE };
*video_codec_list = vob_video_list;
*audio_codec_list = vob_audio_list;
} else if (!strcmp (format_name, "flv")) { } else if (!strcmp (format_name, "flv")) {
static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE }; static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE }; static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
@ -1724,6 +1741,8 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
id = CODEC_ID_ADPCM_CT; id = CODEC_ID_ADPCM_CT;
} else if (!strcmp (layout, "swf")) { } else if (!strcmp (layout, "swf")) {
id = CODEC_ID_ADPCM_SWF; id = CODEC_ID_ADPCM_SWF;
} else if (!strcmp (layout, "yamaha")) {
id = CODEC_ID_ADPCM_YAMAHA;
} }
if (id != CODEC_ID_NONE) if (id != CODEC_ID_NONE)
audio = TRUE; audio = TRUE;
@ -2189,6 +2208,9 @@ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
case CODEC_ID_ADPCM_SWF: case CODEC_ID_ADPCM_SWF:
name = "Shockwave ADPCM"; name = "Shockwave ADPCM";
break; break;
case CODEC_ID_ADPCM_YAMAHA:
name = "Yamaha ADPCM";
break;
case CODEC_ID_RA_144: case CODEC_ID_RA_144:
name = "Realaudio 14k4bps"; name = "Realaudio 14k4bps";
break; break;
@ -2216,6 +2238,15 @@ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
case CODEC_ID_ALAC: case CODEC_ID_ALAC:
name = "Apple lossless audio"; name = "Apple lossless audio";
break; break;
case CODEC_ID_DVD_SUBTITLE:
name = "DVD subtitle";
break;
case CODEC_ID_DVB_SUBTITLE:
name = "DVB subtitle";
break;
case CODEC_ID_FRAPS:
name = "FRAPS video";
break;
default: default:
GST_WARNING ("Unknown codecID 0x%x", codec_id); GST_WARNING ("Unknown codecID 0x%x", codec_id);
break; break;
@ -2544,7 +2575,6 @@ int
gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt, gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt,
const AVPicture * src, int src_pix_fmt, int src_width, int src_height) const AVPicture * src, int src_pix_fmt, int src_width, int src_height)
{ {
int i;
PixFmtInfo *pf = &pix_fmt_info[src_pix_fmt]; PixFmtInfo *pf = &pix_fmt_info[src_pix_fmt];
pf = &pix_fmt_info[src_pix_fmt]; pf = &pix_fmt_info[src_pix_fmt];
@ -2563,6 +2593,3 @@ gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt,
} }
return img_convert (dst, dst_pix_fmt, src, src_pix_fmt, src_width, src_height); return img_convert (dst, dst_pix_fmt, src, src_pix_fmt, src_width, src_height);
} }

View file

@ -132,34 +132,4 @@ gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt,
const AVPicture * src, int src_pix_fmt, const AVPicture * src, int src_pix_fmt,
int src_width, int src_height); int src_width, int src_height);
static inline int64_t
gst_ffmpeg_pts_gst_to_ffmpeg (GstClockTime inpts) {
int64_t outpts;
if (GST_CLOCK_TIME_IS_VALID (inpts))
outpts = (inpts / (GST_SECOND / AV_TIME_BASE));
else
outpts = AV_NOPTS_VALUE;
return outpts;
}
static inline GstClockTime
gst_ffmpeg_pts_ffmpeg_to_gst (int64_t inpts) {
GstClockTime outpts;
if (inpts != AV_NOPTS_VALUE)
outpts = (inpts * (GST_SECOND / AV_TIME_BASE));
else
outpts = GST_CLOCK_TIME_NONE;
return outpts;
}
#endif /* __GST_FFMPEG_CODECMAP_H__ */ #endif /* __GST_FFMPEG_CODECMAP_H__ */

View file

@ -583,20 +583,21 @@ gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec)
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
if (ffmpegdec->format.video.width == ffmpegdec->context->width && if (ffmpegdec->format.video.width == ffmpegdec->context->width &&
ffmpegdec->format.video.height == ffmpegdec->context->height && ffmpegdec->format.video.height == ffmpegdec->context->height &&
ffmpegdec->format.video.fps == ffmpegdec->context->frame_rate && ffmpegdec->format.video.fps == ffmpegdec->context->time_base.den &&
ffmpegdec->format.video.fps_base == ffmpegdec->format.video.fps_base ==
ffmpegdec->context->frame_rate_base && ffmpegdec->context->time_base.num &&
ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt) ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt)
return TRUE; return TRUE;
GST_DEBUG ("Renegotiating video from %dx%d@%d/%dfps to %dx%d@%d/%dfps", GST_DEBUG ("Renegotiating video from %dx%d@%d/%dfps to %dx%d@%d/%dfps",
ffmpegdec->format.video.width, ffmpegdec->format.video.height, ffmpegdec->format.video.width, ffmpegdec->format.video.height,
ffmpegdec->format.video.fps, ffmpegdec->format.video.fps_base, ffmpegdec->format.video.fps, ffmpegdec->format.video.fps_base,
ffmpegdec->context->width, ffmpegdec->context->height, ffmpegdec->context->width, ffmpegdec->context->height,
ffmpegdec->context->frame_rate, ffmpegdec->context->frame_rate_base); ffmpegdec->context->time_base.den,
ffmpegdec->context->time_base.num);
ffmpegdec->format.video.width = ffmpegdec->context->width; ffmpegdec->format.video.width = ffmpegdec->context->width;
ffmpegdec->format.video.height = ffmpegdec->context->height; ffmpegdec->format.video.height = ffmpegdec->context->height;
ffmpegdec->format.video.fps = ffmpegdec->context->frame_rate; ffmpegdec->format.video.fps = ffmpegdec->context->time_base.den;
ffmpegdec->format.video.fps_base = ffmpegdec->context->frame_rate_base; ffmpegdec->format.video.fps_base = ffmpegdec->context->time_base.num;
ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt; ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
break; break;
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
@ -736,11 +737,11 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
} }
GST_BUFFER_TIMESTAMP (outbuf) = ffmpegdec->next_ts; GST_BUFFER_TIMESTAMP (outbuf) = ffmpegdec->next_ts;
if (ffmpegdec->context->frame_rate_base != 0 && if (ffmpegdec->context->time_base.num != 0 &&
ffmpegdec->context->frame_rate != 0) { ffmpegdec->context->time_base.den != 0) {
GST_BUFFER_DURATION (outbuf) = GST_SECOND * GST_BUFFER_DURATION (outbuf) = GST_SECOND *
ffmpegdec->context->frame_rate_base / ffmpegdec->context->time_base.num /
ffmpegdec->context->frame_rate; ffmpegdec->context->time_base.den;
/* Take repeat_pict into account */ /* Take repeat_pict into account */
GST_BUFFER_DURATION (outbuf) += GST_BUFFER_DURATION (outbuf) GST_BUFFER_DURATION (outbuf) += GST_BUFFER_DURATION (outbuf)
@ -760,11 +761,11 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
*in_ts = GST_CLOCK_TIME_NONE; *in_ts = GST_CLOCK_TIME_NONE;
} }
if (ffmpegdec->context->frame_rate_base != 0 && if (ffmpegdec->context->time_base.num != 0 &&
ffmpegdec->context->frame_rate != 0) { ffmpegdec->context->time_base.den != 0) {
guint64 dur = GST_SECOND * guint64 dur = GST_SECOND *
ffmpegdec->context->frame_rate_base / ffmpegdec->context->time_base.num /
ffmpegdec->context->frame_rate; ffmpegdec->context->time_base.den;
/* Take repeat_pict into account */ /* Take repeat_pict into account */
dur += dur * ffmpegdec->picture->repeat_pict / 2; dur += dur * ffmpegdec->picture->repeat_pict / 2;
@ -961,8 +962,9 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
if (ffmpegdec->pctx) { if (ffmpegdec->pctx) {
gint res; gint res;
gint64 ffpts; gint64 ffpts;
AVRational bq = { 1, 1000000000 };
ffpts = gst_ffmpeg_pts_gst_to_ffmpeg (in_ts); ffpts = av_rescale_q (in_ts, bq, ffmpegdec->context->time_base);
res = av_parser_parse (ffmpegdec->pctx, ffmpegdec->context, res = av_parser_parse (ffmpegdec->pctx, ffmpegdec->context,
&data, &size, bdata, bsize, &data, &size, bdata, bsize,
@ -971,7 +973,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
GST_DEBUG_OBJECT (ffmpegdec, "Parsed video frame, res=%d, size=%d", GST_DEBUG_OBJECT (ffmpegdec, "Parsed video frame, res=%d, size=%d",
res, size); res, size);
in_ts = gst_ffmpeg_pts_ffmpeg_to_gst (ffmpegdec->pctx->pts); in_ts = av_rescale_q (in_ts, ffmpegdec->context->time_base, bq);
if (res == 0 || size == 0) if (res == 0 || size == 0)
break; break;
@ -1168,6 +1170,7 @@ gst_ffmpegdec_register (GstPlugin * plugin)
break; break;
} }
if (!gst_element_register (plugin, type_name, rank, type)) { if (!gst_element_register (plugin, type_name, rank, type)) {
g_warning ("Failed to register %s", type_name);
g_free (type_name); g_free (type_name);
return FALSE; return FALSE;
} }

View file

@ -129,10 +129,7 @@ static GstCaps *
gst_ffmpegdeinterlace_getcaps (GstPad * pad) gst_ffmpegdeinterlace_getcaps (GstPad * pad)
{ {
GstFFMpegDeinterlace *filter; GstFFMpegDeinterlace *filter;
GstCaps *othercaps;
GstCaps *caps;
GstPad *otherpad; GstPad *otherpad;
gint i;
filter = GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad)); filter = GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad));
@ -149,7 +146,6 @@ gst_ffmpegdeinterlace_pad_link (GstPad * pad, const GstCaps * caps)
GstStructure *structure; GstStructure *structure;
AVCodecContext *ctx; AVCodecContext *ctx;
GstFFMpegDeinterlace *deinterlace; GstFFMpegDeinterlace *deinterlace;
const GstCaps *othercaps;
GstPad *otherpad; GstPad *otherpad;
GstPadLinkReturn ret; GstPadLinkReturn ret;
int height, width; int height, width;

View file

@ -296,7 +296,7 @@ gst_ffmpegdemux_src_event (GstPad * pad, GstEvent * event)
offset = GST_EVENT_SEEK_OFFSET (event); offset = GST_EVENT_SEEK_OFFSET (event);
switch (GST_EVENT_SEEK_FORMAT (event)) { switch (GST_EVENT_SEEK_FORMAT (event)) {
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
if (stream->codec.codec_type != CODEC_TYPE_VIDEO) { if (stream->codec->codec_type != CODEC_TYPE_VIDEO) {
res = FALSE; res = FALSE;
break; break;
} else { } else {
@ -336,7 +336,7 @@ gst_ffmpegdemux_src_format_list (GstPad * pad)
}, src_a_formats[] = { }, src_a_formats[] = {
GST_FORMAT_TIME, 0}; GST_FORMAT_TIME, 0};
return (stream->codec.codec_type == CODEC_TYPE_VIDEO) ? return (stream->codec->codec_type == CODEC_TYPE_VIDEO) ?
src_v_formats : src_a_formats; src_v_formats : src_a_formats;
} }
@ -371,7 +371,7 @@ gst_ffmpegdemux_src_query (GstPad * pad,
break; break;
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
if (stream->codec_info_nb_frames && if (stream->codec_info_nb_frames &&
stream->codec.codec_type == CODEC_TYPE_VIDEO) { stream->codec->codec_type == CODEC_TYPE_VIDEO) {
*value = stream->codec_info_nb_frames; *value = stream->codec_info_nb_frames;
res = TRUE; res = TRUE;
} }
@ -397,7 +397,7 @@ gst_ffmpegdemux_src_query (GstPad * pad,
} }
break; break;
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
if (stream && stream->codec.codec_type == CODEC_TYPE_VIDEO && if (stream && stream->codec->codec_type == CODEC_TYPE_VIDEO &&
GST_CLOCK_TIME_IS_VALID (demux->last_ts[stream->index])) { GST_CLOCK_TIME_IS_VALID (demux->last_ts[stream->index])) {
res = gst_pad_convert (pad, GST_FORMAT_TIME, res = gst_pad_convert (pad, GST_FORMAT_TIME,
demux->last_ts[stream->index], fmt, value); demux->last_ts[stream->index], fmt, value);
@ -429,15 +429,15 @@ gst_ffmpegdemux_src_convert (GstPad * pad,
AVStream *stream = gst_ffmpegdemux_stream_from_pad (pad); AVStream *stream = gst_ffmpegdemux_stream_from_pad (pad);
gboolean res = TRUE; gboolean res = TRUE;
if (!stream || stream->codec.codec_type != CODEC_TYPE_VIDEO) if (!stream || stream->codec->codec_type != CODEC_TYPE_VIDEO)
return FALSE; return FALSE;
switch (src_fmt) { switch (src_fmt) {
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
switch (*dest_fmt) { switch (*dest_fmt) {
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
*dest_value = src_value * stream->r_frame_rate / *dest_value = src_value * stream->r_frame_rate.num /
(GST_SECOND * stream->r_frame_rate_base); (GST_SECOND * stream->r_frame_rate.den);
break; break;
default: default:
res = FALSE; res = FALSE;
@ -447,8 +447,8 @@ gst_ffmpegdemux_src_convert (GstPad * pad,
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
switch (*dest_fmt) { switch (*dest_fmt) {
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
*dest_value = src_value * GST_SECOND * stream->r_frame_rate_base / *dest_value = src_value * GST_SECOND * stream->r_frame_rate.num /
stream->r_frame_rate; stream->r_frame_rate.den;
break; break;
default: default:
res = FALSE; res = FALSE;
@ -475,7 +475,7 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream)
gchar *padname; gchar *padname;
const gchar *codec; const gchar *codec;
switch (stream->codec.codec_type) { switch (stream->codec->codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
templ = oclass->videosrctempl; templ = oclass->videosrctempl;
num = demux->videopads++; num = demux->videopads++;
@ -485,7 +485,7 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream)
num = demux->audiopads++; num = demux->audiopads++;
break; break;
default: default:
GST_WARNING ("Unknown pad type %d", stream->codec.codec_type); GST_WARNING ("Unknown pad type %d", stream->codec->codec_type);
break; break;
} }
if (!templ) if (!templ)
@ -509,17 +509,17 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream)
/* get caps that belongs to this stream */ /* get caps that belongs to this stream */
caps = caps =
gst_ffmpeg_codecid_to_caps (stream->codec.codec_id, &stream->codec, TRUE); gst_ffmpeg_codecid_to_caps (stream->codec->codec_id, stream->codec, TRUE);
gst_pad_set_explicit_caps (pad, caps); gst_pad_set_explicit_caps (pad, caps);
gst_element_add_pad (GST_ELEMENT (demux), pad); gst_element_add_pad (GST_ELEMENT (demux), pad);
/* metadata */ /* metadata */
if ((codec = gst_ffmpeg_get_codecid_longname (stream->codec.codec_id))) { if ((codec = gst_ffmpeg_get_codecid_longname (stream->codec->codec_id))) {
GstTagList *list = gst_tag_list_new (); GstTagList *list = gst_tag_list_new ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
(stream->codec.codec_type == CODEC_TYPE_VIDEO) ? (stream->codec->codec_type == CODEC_TYPE_VIDEO) ?
GST_TAG_VIDEO_CODEC : GST_TAG_AUDIO_CODEC, codec, NULL); GST_TAG_VIDEO_CODEC : GST_TAG_AUDIO_CODEC, codec, NULL);
gst_element_found_tags_for_pad (GST_ELEMENT (demux), pad, 0, list); gst_element_found_tags_for_pad (GST_ELEMENT (demux), pad, 0, list);
} }
@ -696,7 +696,6 @@ gst_ffmpegdemux_register (GstPlugin * plugin)
GType type; GType type;
AVInputFormat *in_plugin; AVInputFormat *in_plugin;
GstFFMpegDemuxClassParams *params; GstFFMpegDemuxClassParams *params;
AVCodec *in_codec;
gchar **extensions; gchar **extensions;
GTypeInfo typeinfo = { GTypeInfo typeinfo = {
sizeof (GstFFMpegDemuxClass), sizeof (GstFFMpegDemuxClass),

View file

@ -316,8 +316,8 @@ gst_ffmpegenc_getcaps (GstPad * pad)
/* set some default properties */ /* set some default properties */
ctx->width = 384; ctx->width = 384;
ctx->height = 288; ctx->height = 288;
ctx->frame_rate_base = DEFAULT_FRAME_RATE_BASE; ctx->time_base.num = DEFAULT_FRAME_RATE_BASE;
ctx->frame_rate = 25 * DEFAULT_FRAME_RATE_BASE; ctx->time_base.den = 25 * DEFAULT_FRAME_RATE_BASE;
ctx->bit_rate = 350 * 1000; ctx->bit_rate = 350 * 1000;
/* makes it silent */ /* makes it silent */
ctx->strict_std_compliance = -1; ctx->strict_std_compliance = -1;
@ -386,6 +386,10 @@ gst_ffmpegenc_link (GstPad * pad, const GstCaps * caps)
gst_ffmpeg_caps_with_codectype (oclass->in_plugin->type, gst_ffmpeg_caps_with_codectype (oclass->in_plugin->type,
caps, ffmpegenc->context); caps, ffmpegenc->context);
/* FIXME: prevent nego errors because of fixed-caps */
if (!ffmpegenc->context->time_base.den)
ffmpegenc->context->time_base.den = DEFAULT_FRAME_RATE_BASE * 25;
pix_fmt = ffmpegenc->context->pix_fmt; pix_fmt = ffmpegenc->context->pix_fmt;
/* open codec */ /* open codec */
@ -461,16 +465,23 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstData * _data)
GstFFMpegEncClass *oclass = GstFFMpegEncClass *oclass =
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc)); (GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
gint ret_size = 0, frame_size; gint ret_size = 0, frame_size;
const AVRational bq = { 1, 1000000000 };
/* FIXME: events (discont (flush!) and eos (close down) etc.) */ /* FIXME: events (discont (flush!) and eos (close down) etc.) */
GST_DEBUG_OBJECT (ffmpegenc,
"Received buffer of time %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)));
frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture, frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
GST_BUFFER_DATA (inbuf), GST_BUFFER_DATA (inbuf),
ffmpegenc->context->pix_fmt, ffmpegenc->context->pix_fmt,
ffmpegenc->context->width, ffmpegenc->context->height); ffmpegenc->context->width, ffmpegenc->context->height);
g_return_if_fail (frame_size == GST_BUFFER_SIZE (inbuf)); g_return_if_fail (frame_size == GST_BUFFER_SIZE (inbuf));
ffmpegenc->picture->pts = gst_ffmpeg_pts_gst_to_ffmpeg (GST_BUFFER_TIMESTAMP (inbuf)); ffmpegenc->picture->pts =
av_rescale_q (GST_BUFFER_TIMESTAMP (inbuf),
bq, ffmpegenc->context->time_base);
outbuf = gst_buffer_new_and_alloc (ffmpegenc->buffer_size); outbuf = gst_buffer_new_and_alloc (ffmpegenc->buffer_size);
ret_size = avcodec_encode_video (ffmpegenc->context, ret_size = avcodec_encode_video (ffmpegenc->context,
@ -478,8 +489,8 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstData * _data)
GST_BUFFER_MAXSIZE (outbuf), ffmpegenc->picture); GST_BUFFER_MAXSIZE (outbuf), ffmpegenc->picture);
if (ret_size < 0) { if (ret_size < 0) {
GST_ELEMENT_ERROR (ffmpegenc, LIBRARY, ENCODE, (NULL), GST_ERROR_OBJECT (ffmpegenc,
("ffenc_%s: failed to encode buffer", oclass->in_plugin->name)); "ffenc_%s: failed to encode buffer", oclass->in_plugin->name);
gst_buffer_unref (inbuf); gst_buffer_unref (inbuf);
gst_buffer_unref (outbuf); gst_buffer_unref (outbuf);
return; return;
@ -503,8 +514,6 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data)
GstBuffer *inbuf = GST_BUFFER (_data); GstBuffer *inbuf = GST_BUFFER (_data);
GstBuffer *outbuf = NULL, *subbuf; GstBuffer *outbuf = NULL, *subbuf;
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (gst_pad_get_parent (pad)); GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (gst_pad_get_parent (pad));
GstFFMpegEncClass *oclass =
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
gint size, ret_size = 0, in_size, frame_size; gint size, ret_size = 0, in_size, frame_size;
size = GST_BUFFER_SIZE (inbuf); size = GST_BUFFER_SIZE (inbuf);
@ -517,6 +526,10 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data)
if (ffmpegenc->cache) if (ffmpegenc->cache)
in_size += GST_BUFFER_SIZE (ffmpegenc->cache); in_size += GST_BUFFER_SIZE (ffmpegenc->cache);
GST_DEBUG_OBJECT (ffmpegenc,
"Received buffer of time %" GST_TIME_FORMAT " and size %d (cache: %d)",
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)), size, in_size - size);
while (1) { while (1) {
/* do we have enough data for one frame? */ /* do we have enough data for one frame? */
if (in_size / (2 * ffmpegenc->context->channels) < if (in_size / (2 * ffmpegenc->context->channels) <
@ -569,7 +582,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data)
GST_BUFFER_DATA (subbuf)); GST_BUFFER_DATA (subbuf));
if (ret_size < 0) { if (ret_size < 0) {
g_warning ("ffenc_%s: failed to encode buffer", oclass->in_plugin->name); GST_ERROR_OBJECT (ffmpegenc, "Failed to encode buffer");
gst_buffer_unref (inbuf); gst_buffer_unref (inbuf);
gst_buffer_unref (outbuf); gst_buffer_unref (outbuf);
gst_buffer_unref (subbuf); gst_buffer_unref (subbuf);

View file

@ -247,11 +247,13 @@ gst_ffmpegmux_request_new_pad (GstElement * element,
/* AVStream needs to be created */ /* AVStream needs to be created */
st = av_new_stream (ffmpegmux->context, padnum); st = av_new_stream (ffmpegmux->context, padnum);
st->codec.codec_type = type; st->codec->codec_type = type;
st->codec.codec_id = CODEC_ID_NONE; /* this is a check afterwards */ st->codec->codec_id = CODEC_ID_NONE; /* this is a check afterwards */
st->stream_copy = 1; /* we're not the actual encoder */ st->stream_copy = 1; /* we're not the actual encoder */
st->codec.bit_rate = bitrate; st->codec->bit_rate = bitrate;
st->codec.frame_size = framesize; st->codec->frame_size = framesize;
st->time_base.den = GST_SECOND;
st->time_base.num = 1;
/* we fill in codec during capsnego */ /* we fill in codec during capsnego */
/* we love debug output (c) (tm) (r) */ /* we love debug output (c) (tm) (r) */
@ -284,7 +286,7 @@ gst_ffmpegmux_connect (GstPad * pad, const GstCaps * caps)
/* for the format-specific guesses, we'll go to /* for the format-specific guesses, we'll go to
* our famous codec mapper */ * our famous codec mapper */
if (gst_ffmpeg_caps_to_codecid (caps, &st->codec) != CODEC_ID_NONE) { if (gst_ffmpeg_caps_to_codecid (caps, st->codec) != CODEC_ID_NONE) {
ffmpegmux->eos[i] = FALSE; ffmpegmux->eos[i] = FALSE;
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
@ -350,16 +352,16 @@ gst_ffmpegmux_loop (GstElement * element)
AVStream *st = ffmpegmux->context->streams[i]; AVStream *st = ffmpegmux->context->streams[i];
/* check whether the pad has successfully completed capsnego */ /* check whether the pad has successfully completed capsnego */
if (st->codec.codec_id == CODEC_ID_NONE) { if (st->codec->codec_id == CODEC_ID_NONE) {
GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL), GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
("no caps set on stream %d (%s)", i, ("no caps set on stream %d (%s)", i,
(st->codec.codec_type == CODEC_TYPE_VIDEO) ? (st->codec->codec_type == CODEC_TYPE_VIDEO) ?
"video" : "audio")); "video" : "audio"));
return; return;
} }
if (st->codec.codec_type == CODEC_TYPE_AUDIO) { if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
st->codec.frame_size = st->codec->frame_size =
st->codec.sample_rate * st->codec->sample_rate *
GST_BUFFER_DURATION (ffmpegmux->bufferqueue[i]) / GST_SECOND; GST_BUFFER_DURATION (ffmpegmux->bufferqueue[i]) / GST_SECOND;
} }
} }
@ -470,15 +472,17 @@ gst_ffmpegmux_loop (GstElement * element)
if (bufnum >= 0) { if (bufnum >= 0) {
GstBuffer *buf; GstBuffer *buf;
AVPacket pkt; AVPacket pkt;
AVRational bq = { 1, 1000000000 };
/* push out current buffer */ /* push out current buffer */
buf = ffmpegmux->bufferqueue[bufnum]; buf = ffmpegmux->bufferqueue[bufnum];
ffmpegmux->bufferqueue[bufnum] = NULL; ffmpegmux->bufferqueue[bufnum] = NULL;
ffmpegmux->context->streams[bufnum]->codec.frame_number++; ffmpegmux->context->streams[bufnum]->codec->frame_number++;
/* set time */ /* set time */
pkt.pts = GST_BUFFER_TIMESTAMP (buf) * AV_TIME_BASE / GST_SECOND; pkt.pts = av_rescale_q (GST_BUFFER_TIMESTAMP (buf),
bq, ffmpegmux->context->streams[bufnum]->time_base);
pkt.dts = pkt.pts; pkt.dts = pkt.pts;
pkt.data = GST_BUFFER_DATA (buf); pkt.data = GST_BUFFER_DATA (buf);
pkt.size = GST_BUFFER_SIZE (buf); pkt.size = GST_BUFFER_SIZE (buf);
@ -563,7 +567,6 @@ gst_ffmpegmux_register (GstPlugin * plugin)
GType type; GType type;
AVOutputFormat *in_plugin; AVOutputFormat *in_plugin;
GstFFMpegMuxClassParams *params; GstFFMpegMuxClassParams *params;
AVCodec *in_codec;
in_plugin = first_oformat; in_plugin = first_oformat;

View file

@ -212,7 +212,6 @@ gst_ffmpegdata_write (URLContext * h, unsigned char *buf, int size)
if (info->set_streamheader) { if (info->set_streamheader) {
GstCaps *caps = gst_pad_get_caps (info->pad); GstCaps *caps = gst_pad_get_caps (info->pad);
GList *bufs = NULL;
GstStructure *structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
GValue list = { 0 }, value = { 0 }; GValue list = { 0 }, value = { 0 };

View file

@ -167,12 +167,9 @@ gst_ffmpegscale_pad_link (GstPad * pad, const GstCaps * caps)
GstStructure *structure; GstStructure *structure;
AVCodecContext *ctx; AVCodecContext *ctx;
GstFFMpegScale *scale; GstFFMpegScale *scale;
const GstCaps *othercaps;
GstPad *otherpad; GstPad *otherpad;
GstPadLinkReturn ret; GstPadLinkReturn ret;
int height, width; int height, width;
double framerate;
const GValue *par = NULL;
gchar *caps_string; gchar *caps_string;
caps_string = gst_caps_to_string (caps); caps_string = gst_caps_to_string (caps);

View file

@ -335,9 +335,7 @@ gst_postproc_chain (GstPad * pad, GstData * data)
GstPostProc *postproc; GstPostProc *postproc;
GstBuffer *in, *out; GstBuffer *in, *out;
int stride[3]; int stride[3];
unsigned char * inplane[3];
unsigned char * outplane[3]; unsigned char * outplane[3];
gint pixdif, i;
GST_DEBUG("chaining"); GST_DEBUG("chaining");