+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>
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__ */
/* 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);
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;
if (ffmpegdec->last_buffer != NULL) {
gst_buffer_unref (ffmpegdec->last_buffer);
}
-
- /* closing context.. unref buffers? */
-
gst_ffmpegdec_close (ffmpegdec);
break;
}
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,