You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/ylc: add frame threading support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "huffyuvdsp.h"
|
#include "huffyuvdsp.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "thread.h"
|
||||||
#include "unary.h"
|
#include "unary.h"
|
||||||
|
|
||||||
typedef struct YLCContext {
|
typedef struct YLCContext {
|
||||||
@@ -282,6 +283,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
int TL[4] = { 128, 128, 128, 128 };
|
int TL[4] = { 128, 128, 128, 128 };
|
||||||
int L[4] = { 128, 128, 128, 128 };
|
int L[4] = { 128, 128, 128, 128 };
|
||||||
YLCContext *s = avctx->priv_data;
|
YLCContext *s = avctx->priv_data;
|
||||||
|
ThreadFrame frame = { .f = data };
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int ret, x, y, toffset, boffset;
|
int ret, x, y, toffset, boffset;
|
||||||
AVFrame * const p = data;
|
AVFrame * const p = data;
|
||||||
@@ -303,7 +305,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
if (toffset >= boffset || boffset >= avpkt->size)
|
if (toffset >= boffset || boffset >= avpkt->size)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
av_fast_malloc(&s->table_bits, &s->table_bits_size,
|
av_fast_malloc(&s->table_bits, &s->table_bits_size,
|
||||||
@@ -447,6 +449,24 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return avpkt->size;
|
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)
|
static av_cold int decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
YLCContext *s = avctx->priv_data;
|
YLCContext *s = avctx->priv_data;
|
||||||
@@ -470,7 +490,8 @@ AVCodec ff_ylc_decoder = {
|
|||||||
.id = AV_CODEC_ID_YLC,
|
.id = AV_CODEC_ID_YLC,
|
||||||
.priv_data_size = sizeof(YLCContext),
|
.priv_data_size = sizeof(YLCContext),
|
||||||
.init = decode_init,
|
.init = decode_init,
|
||||||
|
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
|
||||||
.close = decode_end,
|
.close = decode_end,
|
||||||
.decode = decode_frame,
|
.decode = decode_frame,
|
||||||
.capabilities = AV_CODEC_CAP_DR1,
|
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user