[FFmpeg-cvslog] lavc: add ff_init_buffer_info()
Michael Niedermayer
git at videolan.org
Fri Oct 7 02:31:44 CEST 2011
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Oct 7 02:11:06 2011 +0200| [b93cb8383fec0aa95b735fcd97eff03425e79bc1] | committer: Michael Niedermayer
lavc: add ff_init_buffer_info()
Fixes seeking per fileposition in ffplay.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b93cb8383fec0aa95b735fcd97eff03425e79bc1
---
libavcodec/internal.h | 5 +++++
libavcodec/pthread.c | 3 +++
libavcodec/utils.c | 19 +++++++++++++++++++
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 75d7f37..68f49b5 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -55,4 +55,9 @@ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
unsigned int ff_toupper4(unsigned int x);
+/**
+ * does needed setup of pkt_pts/pos and such for (re)get_buffer();
+ */
+void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic);
+
#endif /* AVCODEC_INTERNAL_H */
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 0810491..454e51f 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -32,6 +32,7 @@
#include <pthread.h>
#include "avcodec.h"
+#include "internal.h"
#include "thread.h"
typedef int (action_func)(AVCodecContext *c, void *arg);
@@ -787,6 +788,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
f->owner = avctx;
+ ff_init_buffer_info(avctx, f);
+
if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
f->thread_opaque = NULL;
return avctx->get_buffer(avctx, f);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 8af4c33..f28b024 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -238,6 +238,22 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
*width=FFALIGN(*width, align);
}
+void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic)
+{
+ if (s->pkt) {
+ pic->pkt_pts = s->pkt->pts;
+ pic->pkt_pos = s->pkt->pos;
+ } else {
+ pic->pkt_pts = AV_NOPTS_VALUE;
+ pic->pkt_pos = -1;
+ }
+ pic->reordered_opaque= s->reordered_opaque;
+ pic->sample_aspect_ratio = s->sample_aspect_ratio;
+ pic->width = s->width;
+ pic->height = s->height;
+ pic->format = s->pix_fmt;
+}
+
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
int w= s->width;
@@ -1357,6 +1373,9 @@ unsigned int ff_toupper4(unsigned int x)
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
{
f->owner = avctx;
+
+ ff_init_buffer_info(avctx, f);
+
return avctx->get_buffer(avctx, f);
}
More information about the ffmpeg-cvslog
mailing list