Commit 6e5fa03b authored by Luca Ognibene's avatar Luca Ognibene

ext/ffmpeg/: Makes ffmpegdec and ffmpegenc use these functions and remove a...

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
parent d840f938
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>
......
......@@ -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__ */
......@@ -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;
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment