ext/ffmpeg/: Makes ffmpegdec and ffmpegenc use these functions and remove a comment from a previuos patch

Original commit message from CVS:
* ext/ffmpeg/gstffmpegenc.c (gst_ffmpegenc_chain_video):
* ext/ffmpeg/gstffmpegdec.c (gst_ffmpegdec_chain):
Makes ffmpegdec and ffmpegenc use these functions
and remove a comment from a previuos patch

* ext/ffmpeg/gstffmpegcodecmap.h:
Add two utility functions to convert the pts from/to
the ffmpeg format
This commit is contained in:
Luca Ognibene 2005-05-11 15:18:23 +00:00
parent d840f938cd
commit 6e5fa03b6b
4 changed files with 45 additions and 10 deletions

View file

@ -1,3 +1,14 @@
2005-05-11 Luca Ognibene <luogni@luogni@tin.it>
* ext/ffmpeg/gstffmpegenc.c (gst_ffmpegenc_chain_video):
* ext/ffmpeg/gstffmpegdec.c (gst_ffmpegdec_chain):
Makes ffmpegdec and ffmpegenc use these functions
and remove a comment from a previuos patch
* ext/ffmpeg/gstffmpegcodecmap.h:
Add two utility functions to convert the pts from/to
the ffmpeg format
2005-05-06 Luca Ognibene <luogni@tin.it>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>

View file

@ -132,5 +132,34 @@ 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__ */

View file

@ -944,11 +944,10 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
/* parse, if at all possible */
if (ffmpegdec->pctx) {
gint res;
gint64 ffpts = AV_NOPTS_VALUE;
gint64 ffpts;
ffpts = gst_ffmpeg_pts_gst_to_ffmpeg (in_ts);
if (GST_CLOCK_TIME_IS_VALID (in_ts))
ffpts = in_ts / (GST_SECOND / AV_TIME_BASE);
res = av_parser_parse (ffmpegdec->pctx, ffmpegdec->context,
&data, &size, bdata, bsize,
ffpts, ffpts);
@ -956,8 +955,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
GST_DEBUG_OBJECT (ffmpegdec, "Parsed video frame, res=%d, size=%d",
res, size);
if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE)
in_ts = ffmpegdec->pctx->pts * (GST_SECOND / AV_TIME_BASE);
in_ts = gst_ffmpeg_pts_ffmpeg_to_gst (ffmpegdec->pctx->pts);
if (res == 0 || size == 0)
break;
@ -1005,9 +1003,6 @@ gst_ffmpegdec_change_state (GstElement * element)
if (ffmpegdec->last_buffer != NULL) {
gst_buffer_unref (ffmpegdec->last_buffer);
}
/* closing context.. unref buffers? */
gst_ffmpegdec_close (ffmpegdec);
break;
}

View file

@ -468,7 +468,7 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstData * _data)
ffmpegenc->context->width, ffmpegenc->context->height);
g_return_if_fail (frame_size == GST_BUFFER_SIZE (inbuf));
ffmpegenc->picture->pts = GST_BUFFER_TIMESTAMP (inbuf) / 1000;
ffmpegenc->picture->pts = gst_ffmpeg_pts_gst_to_ffmpeg (GST_BUFFER_TIMESTAMP (inbuf));
outbuf = gst_buffer_new_and_alloc (ffmpegenc->buffer_size);
ret_size = avcodec_encode_video (ffmpegenc->context,