diff --git a/ChangeLog b/ChangeLog index e63d133ae2..77a5d90fe7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2005-07-20 Ronald S. Bultje + + * 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 Reviewed by: Ronald S. Bultje diff --git a/common b/common index ac7272b7af..6f9b691adc 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit ac7272b7af934c2294a44ac1c0f3fac3f8d17ec6 +Subproject commit 6f9b691adc2a0300598311671dd7c4d9d2035afa diff --git a/ext/ffmpeg/gstffmpeg.h b/ext/ffmpeg/gstffmpeg.h index 4cab7cd096..b4bd8ce67f 100644 --- a/ext/ffmpeg/gstffmpeg.h +++ b/ext/ffmpeg/gstffmpeg.h @@ -44,6 +44,8 @@ extern gboolean gst_ffmpegdec_register (GstPlugin * plugin); extern gboolean gst_ffmpegenc_register (GstPlugin * plugin); extern gboolean gst_ffmpegmux_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 diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index 3eff0923ef..09f1b83fe3 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -86,8 +86,9 @@ gst_ffmpeg_set_palette (GstCaps *caps, AVCodecContext *context) gst_caps_new_simple (mimetype, \ "width", G_TYPE_INT, context->width, \ "height", G_TYPE_INT, context->height, \ - "framerate", G_TYPE_DOUBLE, 1. * context->frame_rate / \ - context->frame_rate_base, \ + "framerate", G_TYPE_DOUBLE, 1. * \ + context->time_base.den / \ + context->time_base.num, \ __VA_ARGS__, NULL) \ : \ 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); break; + case CODEC_ID_FRAPS: case CODEC_ID_VCR1: case CODEC_ID_CLJR: 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_CT: case CODEC_ID_ADPCM_SWF: + case CODEC_ID_ADPCM_YAMAHA: do { gchar *layout = NULL; @@ -635,6 +638,9 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, case CODEC_ID_ADPCM_SWF: layout = "swf"; break; + case CODEC_ID_ADPCM_YAMAHA: + layout = "yamaha"; + break; default: g_assert (0); /* don't worry, we never get here */ break; @@ -726,6 +732,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, } break; + case CODEC_ID_DVD_SUBTITLE: + case CODEC_ID_DVB_SUBTITLE: + caps = NULL; + break; + default: g_warning ("Unknown codec ID %d, please add here", codec_id); break; @@ -1089,8 +1100,8 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, gst_structure_get_int (structure, "bpp", &context->bits_per_sample); if (gst_structure_get_double (structure, "framerate", &fps)) { - context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE; - context->frame_rate_base = DEFAULT_FRAME_RATE_BASE; + context->time_base.den = fps * DEFAULT_FRAME_RATE_BASE; + context->time_base.num = DEFAULT_FRAME_RATE_BASE; } 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) { 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 }; *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; *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")) { static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, 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; } else if (!strcmp (layout, "swf")) { id = CODEC_ID_ADPCM_SWF; + } else if (!strcmp (layout, "yamaha")) { + id = CODEC_ID_ADPCM_YAMAHA; } if (id != CODEC_ID_NONE) audio = TRUE; @@ -2189,6 +2208,9 @@ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id) case CODEC_ID_ADPCM_SWF: name = "Shockwave ADPCM"; break; + case CODEC_ID_ADPCM_YAMAHA: + name = "Yamaha ADPCM"; + break; case CODEC_ID_RA_144: name = "Realaudio 14k4bps"; break; @@ -2216,6 +2238,15 @@ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id) case CODEC_ID_ALAC: name = "Apple lossless audio"; 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: GST_WARNING ("Unknown codecID 0x%x", codec_id); break; @@ -2544,7 +2575,6 @@ int gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt, const AVPicture * src, int src_pix_fmt, int src_width, int src_height) { - int i; PixFmtInfo *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); } - - - diff --git a/ext/ffmpeg/gstffmpegcodecmap.h b/ext/ffmpeg/gstffmpegcodecmap.h index c4bd1d68e7..8b6822fab9 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.h +++ b/ext/ffmpeg/gstffmpegcodecmap.h @@ -132,34 +132,4 @@ gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt, const AVPicture * src, int src_pix_fmt, 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__ */ - diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index 4cd16b57d1..d3c1f7754e 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -583,20 +583,21 @@ gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec) case CODEC_TYPE_VIDEO: if (ffmpegdec->format.video.width == ffmpegdec->context->width && 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->context->time_base.num && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt) return TRUE; 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.fps, ffmpegdec->format.video.fps_base, 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.height = ffmpegdec->context->height; - ffmpegdec->format.video.fps = ffmpegdec->context->frame_rate; - ffmpegdec->format.video.fps_base = ffmpegdec->context->frame_rate_base; + ffmpegdec->format.video.fps = ffmpegdec->context->time_base.den; + ffmpegdec->format.video.fps_base = ffmpegdec->context->time_base.num; ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt; break; case CODEC_TYPE_AUDIO: @@ -736,11 +737,11 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec, } GST_BUFFER_TIMESTAMP (outbuf) = ffmpegdec->next_ts; - if (ffmpegdec->context->frame_rate_base != 0 && - ffmpegdec->context->frame_rate != 0) { + if (ffmpegdec->context->time_base.num != 0 && + ffmpegdec->context->time_base.den != 0) { GST_BUFFER_DURATION (outbuf) = GST_SECOND * - ffmpegdec->context->frame_rate_base / - ffmpegdec->context->frame_rate; + ffmpegdec->context->time_base.num / + ffmpegdec->context->time_base.den; /* Take repeat_pict into account */ GST_BUFFER_DURATION (outbuf) += GST_BUFFER_DURATION (outbuf) @@ -760,11 +761,11 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec, *in_ts = GST_CLOCK_TIME_NONE; } - if (ffmpegdec->context->frame_rate_base != 0 && - ffmpegdec->context->frame_rate != 0) { + if (ffmpegdec->context->time_base.num != 0 && + ffmpegdec->context->time_base.den != 0) { guint64 dur = GST_SECOND * - ffmpegdec->context->frame_rate_base / - ffmpegdec->context->frame_rate; + ffmpegdec->context->time_base.num / + ffmpegdec->context->time_base.den; /* Take repeat_pict into account */ dur += dur * ffmpegdec->picture->repeat_pict / 2; @@ -961,8 +962,9 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data) if (ffmpegdec->pctx) { gint res; 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, &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", 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) break; @@ -1168,6 +1170,7 @@ gst_ffmpegdec_register (GstPlugin * plugin) break; } if (!gst_element_register (plugin, type_name, rank, type)) { + g_warning ("Failed to register %s", type_name); g_free (type_name); return FALSE; } diff --git a/ext/ffmpeg/gstffmpegdeinterlace.c b/ext/ffmpeg/gstffmpegdeinterlace.c index fbb15e3d71..0bc76b2b06 100644 --- a/ext/ffmpeg/gstffmpegdeinterlace.c +++ b/ext/ffmpeg/gstffmpegdeinterlace.c @@ -129,10 +129,7 @@ static GstCaps * gst_ffmpegdeinterlace_getcaps (GstPad * pad) { GstFFMpegDeinterlace *filter; - GstCaps *othercaps; - GstCaps *caps; GstPad *otherpad; - gint i; filter = GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad)); @@ -149,7 +146,6 @@ gst_ffmpegdeinterlace_pad_link (GstPad * pad, const GstCaps * caps) GstStructure *structure; AVCodecContext *ctx; GstFFMpegDeinterlace *deinterlace; - const GstCaps *othercaps; GstPad *otherpad; GstPadLinkReturn ret; int height, width; diff --git a/ext/ffmpeg/gstffmpegdemux.c b/ext/ffmpeg/gstffmpegdemux.c index 3677d59607..3cbdf2f4de 100644 --- a/ext/ffmpeg/gstffmpegdemux.c +++ b/ext/ffmpeg/gstffmpegdemux.c @@ -296,7 +296,7 @@ gst_ffmpegdemux_src_event (GstPad * pad, GstEvent * event) offset = GST_EVENT_SEEK_OFFSET (event); switch (GST_EVENT_SEEK_FORMAT (event)) { case GST_FORMAT_DEFAULT: - if (stream->codec.codec_type != CODEC_TYPE_VIDEO) { + if (stream->codec->codec_type != CODEC_TYPE_VIDEO) { res = FALSE; break; } else { @@ -336,7 +336,7 @@ gst_ffmpegdemux_src_format_list (GstPad * pad) }, src_a_formats[] = { 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; } @@ -371,7 +371,7 @@ gst_ffmpegdemux_src_query (GstPad * pad, break; case GST_FORMAT_DEFAULT: 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; res = TRUE; } @@ -397,7 +397,7 @@ gst_ffmpegdemux_src_query (GstPad * pad, } break; 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])) { res = gst_pad_convert (pad, GST_FORMAT_TIME, 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); gboolean res = TRUE; - if (!stream || stream->codec.codec_type != CODEC_TYPE_VIDEO) + if (!stream || stream->codec->codec_type != CODEC_TYPE_VIDEO) return FALSE; switch (src_fmt) { case GST_FORMAT_TIME: switch (*dest_fmt) { case GST_FORMAT_DEFAULT: - *dest_value = src_value * stream->r_frame_rate / - (GST_SECOND * stream->r_frame_rate_base); + *dest_value = src_value * stream->r_frame_rate.num / + (GST_SECOND * stream->r_frame_rate.den); break; default: res = FALSE; @@ -447,8 +447,8 @@ gst_ffmpegdemux_src_convert (GstPad * pad, case GST_FORMAT_DEFAULT: switch (*dest_fmt) { case GST_FORMAT_TIME: - *dest_value = src_value * GST_SECOND * stream->r_frame_rate_base / - stream->r_frame_rate; + *dest_value = src_value * GST_SECOND * stream->r_frame_rate.num / + stream->r_frame_rate.den; break; default: res = FALSE; @@ -475,7 +475,7 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream) gchar *padname; const gchar *codec; - switch (stream->codec.codec_type) { + switch (stream->codec->codec_type) { case CODEC_TYPE_VIDEO: templ = oclass->videosrctempl; num = demux->videopads++; @@ -485,7 +485,7 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream) num = demux->audiopads++; break; default: - GST_WARNING ("Unknown pad type %d", stream->codec.codec_type); + GST_WARNING ("Unknown pad type %d", stream->codec->codec_type); break; } if (!templ) @@ -509,17 +509,17 @@ gst_ffmpegdemux_add (GstFFMpegDemux * demux, AVStream * stream) /* get caps that belongs to this stream */ 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_element_add_pad (GST_ELEMENT (demux), pad); /* 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 (); 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_element_found_tags_for_pad (GST_ELEMENT (demux), pad, 0, list); } @@ -696,7 +696,6 @@ gst_ffmpegdemux_register (GstPlugin * plugin) GType type; AVInputFormat *in_plugin; GstFFMpegDemuxClassParams *params; - AVCodec *in_codec; gchar **extensions; GTypeInfo typeinfo = { sizeof (GstFFMpegDemuxClass), diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c index 1b52db6347..cbd87ba85b 100644 --- a/ext/ffmpeg/gstffmpegenc.c +++ b/ext/ffmpeg/gstffmpegenc.c @@ -316,8 +316,8 @@ gst_ffmpegenc_getcaps (GstPad * pad) /* set some default properties */ ctx->width = 384; ctx->height = 288; - ctx->frame_rate_base = DEFAULT_FRAME_RATE_BASE; - ctx->frame_rate = 25 * DEFAULT_FRAME_RATE_BASE; + ctx->time_base.num = DEFAULT_FRAME_RATE_BASE; + ctx->time_base.den = 25 * DEFAULT_FRAME_RATE_BASE; ctx->bit_rate = 350 * 1000; /* makes it silent */ 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, 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; /* open codec */ @@ -461,16 +465,23 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstData * _data) GstFFMpegEncClass *oclass = (GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc)); gint ret_size = 0, frame_size; + const AVRational bq = { 1, 1000000000 }; /* 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, GST_BUFFER_DATA (inbuf), ffmpegenc->context->pix_fmt, ffmpegenc->context->width, ffmpegenc->context->height); 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); 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); if (ret_size < 0) { - GST_ELEMENT_ERROR (ffmpegenc, LIBRARY, ENCODE, (NULL), - ("ffenc_%s: failed to encode buffer", oclass->in_plugin->name)); + GST_ERROR_OBJECT (ffmpegenc, + "ffenc_%s: failed to encode buffer", oclass->in_plugin->name); gst_buffer_unref (inbuf); gst_buffer_unref (outbuf); return; @@ -503,8 +514,6 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data) GstBuffer *inbuf = GST_BUFFER (_data); GstBuffer *outbuf = NULL, *subbuf; 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; size = GST_BUFFER_SIZE (inbuf); @@ -517,6 +526,10 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data) if (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) { /* do we have enough data for one frame? */ if (in_size / (2 * ffmpegenc->context->channels) < @@ -569,7 +582,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstData * _data) GST_BUFFER_DATA (subbuf)); 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 (outbuf); gst_buffer_unref (subbuf); diff --git a/ext/ffmpeg/gstffmpegmux.c b/ext/ffmpeg/gstffmpegmux.c index 7c1fcbc73e..839ec5fe87 100644 --- a/ext/ffmpeg/gstffmpegmux.c +++ b/ext/ffmpeg/gstffmpegmux.c @@ -247,11 +247,13 @@ gst_ffmpegmux_request_new_pad (GstElement * element, /* AVStream needs to be created */ st = av_new_stream (ffmpegmux->context, padnum); - st->codec.codec_type = type; - st->codec.codec_id = CODEC_ID_NONE; /* this is a check afterwards */ + st->codec->codec_type = type; + st->codec->codec_id = CODEC_ID_NONE; /* this is a check afterwards */ st->stream_copy = 1; /* we're not the actual encoder */ - st->codec.bit_rate = bitrate; - st->codec.frame_size = framesize; + st->codec->bit_rate = bitrate; + st->codec->frame_size = framesize; + st->time_base.den = GST_SECOND; + st->time_base.num = 1; /* we fill in codec during capsnego */ /* 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 * 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; return GST_PAD_LINK_OK; } @@ -350,16 +352,16 @@ gst_ffmpegmux_loop (GstElement * element) AVStream *st = ffmpegmux->context->streams[i]; /* 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), ("no caps set on stream %d (%s)", i, - (st->codec.codec_type == CODEC_TYPE_VIDEO) ? + (st->codec->codec_type == CODEC_TYPE_VIDEO) ? "video" : "audio")); return; } - if (st->codec.codec_type == CODEC_TYPE_AUDIO) { - st->codec.frame_size = - st->codec.sample_rate * + if (st->codec->codec_type == CODEC_TYPE_AUDIO) { + st->codec->frame_size = + st->codec->sample_rate * GST_BUFFER_DURATION (ffmpegmux->bufferqueue[i]) / GST_SECOND; } } @@ -470,15 +472,17 @@ gst_ffmpegmux_loop (GstElement * element) if (bufnum >= 0) { GstBuffer *buf; AVPacket pkt; + AVRational bq = { 1, 1000000000 }; /* push out current buffer */ buf = ffmpegmux->bufferqueue[bufnum]; ffmpegmux->bufferqueue[bufnum] = NULL; - ffmpegmux->context->streams[bufnum]->codec.frame_number++; + ffmpegmux->context->streams[bufnum]->codec->frame_number++; /* 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.data = GST_BUFFER_DATA (buf); pkt.size = GST_BUFFER_SIZE (buf); @@ -563,7 +567,6 @@ gst_ffmpegmux_register (GstPlugin * plugin) GType type; AVOutputFormat *in_plugin; GstFFMpegMuxClassParams *params; - AVCodec *in_codec; in_plugin = first_oformat; diff --git a/ext/ffmpeg/gstffmpegprotocol.c b/ext/ffmpeg/gstffmpegprotocol.c index b10178c67f..759b52fe6d 100644 --- a/ext/ffmpeg/gstffmpegprotocol.c +++ b/ext/ffmpeg/gstffmpegprotocol.c @@ -212,7 +212,6 @@ gst_ffmpegdata_write (URLContext * h, unsigned char *buf, int size) if (info->set_streamheader) { GstCaps *caps = gst_pad_get_caps (info->pad); - GList *bufs = NULL; GstStructure *structure = gst_caps_get_structure (caps, 0); GValue list = { 0 }, value = { 0 }; diff --git a/ext/ffmpeg/gstffmpegscale.c b/ext/ffmpeg/gstffmpegscale.c index d787be8e75..95ae5fb0fa 100644 --- a/ext/ffmpeg/gstffmpegscale.c +++ b/ext/ffmpeg/gstffmpegscale.c @@ -167,12 +167,9 @@ gst_ffmpegscale_pad_link (GstPad * pad, const GstCaps * caps) GstStructure *structure; AVCodecContext *ctx; GstFFMpegScale *scale; - const GstCaps *othercaps; GstPad *otherpad; GstPadLinkReturn ret; int height, width; - double framerate; - const GValue *par = NULL; gchar *caps_string; caps_string = gst_caps_to_string (caps); diff --git a/ext/libpostproc/gstpostproc.c b/ext/libpostproc/gstpostproc.c index 5a232692a7..b4e9138cd4 100644 --- a/ext/libpostproc/gstpostproc.c +++ b/ext/libpostproc/gstpostproc.c @@ -335,9 +335,7 @@ gst_postproc_chain (GstPad * pad, GstData * data) GstPostProc *postproc; GstBuffer *in, *out; int stride[3]; - unsigned char * inplane[3]; unsigned char * outplane[3]; - gint pixdif, i; GST_DEBUG("chaining");