[FFmpeg-cvslog] avcodec/ylc: add frame threading support
Paul B Mahol
git at videolan.org
Mon Dec 26 21:44:27 EET 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Dec 26 20:27:01 2016 +0100| [31bf37cba8ff1e385d38653e0381485c3a8b4c8a] | committer: Paul B Mahol
avcodec/ylc: add frame threading support
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31bf37cba8ff1e385d38653e0381485c3a8b4c8a
---
libavcodec/ylc.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
index 81a5774..3230c56 100644
--- a/libavcodec/ylc.c
+++ b/libavcodec/ylc.c
@@ -31,6 +31,7 @@
#include "get_bits.h"
#include "huffyuvdsp.h"
#include "internal.h"
+#include "thread.h"
#include "unary.h"
typedef struct YLCContext {
@@ -282,6 +283,7 @@ static int decode_frame(AVCodecContext *avctx,
int TL[4] = { 128, 128, 128, 128 };
int L[4] = { 128, 128, 128, 128 };
YLCContext *s = avctx->priv_data;
+ ThreadFrame frame = { .f = data };
const uint8_t *buf = avpkt->data;
int ret, x, y, toffset, boffset;
AVFrame * const p = data;
@@ -303,7 +305,7 @@ static int decode_frame(AVCodecContext *avctx,
if (toffset >= boffset || boffset >= avpkt->size)
return AVERROR_INVALIDDATA;
- if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
av_fast_malloc(&s->table_bits, &s->table_bits_size,
@@ -447,6 +449,24 @@ static int decode_frame(AVCodecContext *avctx,
return avpkt->size;
}
+#if HAVE_THREADS
+static int init_thread_copy(AVCodecContext *avctx)
+{
+ YLCContext *s = avctx->priv_data;
+
+ memset(&s->vlc[0], 0, sizeof(VLC));
+ memset(&s->vlc[1], 0, sizeof(VLC));
+ memset(&s->vlc[2], 0, sizeof(VLC));
+ memset(&s->vlc[3], 0, sizeof(VLC));
+ s->table_bits = NULL;
+ s->table_bits_size = 0;
+ s->bitstream_bits = NULL;
+ s->bitstream_bits_size = 0;
+
+ return 0;
+}
+#endif
+
static av_cold int decode_end(AVCodecContext *avctx)
{
YLCContext *s = avctx->priv_data;
@@ -470,7 +490,8 @@ AVCodec ff_ylc_decoder = {
.id = AV_CODEC_ID_YLC,
.priv_data_size = sizeof(YLCContext),
.init = decode_init,
+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.close = decode_end,
.decode = decode_frame,
- .capabilities = AV_CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
};
More information about the ffmpeg-cvslog
mailing list