[FFmpeg-devel] [PATCH 14/17] mjpegdec: Add hwaccel hooks
Mark Thompson
sw at jkqxz.net
Fri Nov 24 13:18:03 EET 2017
On 24/11/17 07:25, Jun Zhao wrote:
>
>
> On 2017/11/24 8:51, Mark Thompson wrote:
>> Also adds some extra fields to the main context structure that may
>> be needed by a hwaccel decoder.
>> ---
>> The YUVJ formats really mess with this. This patch hacks them out so that the hwaccel works, suggestions welcome on what to actually do about them.
>>
>>
>> libavcodec/mjpegdec.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++--
>> libavcodec/mjpegdec.h | 11 ++++++++
>> 2 files changed, 79 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
>> index f01d44a169..846dec2f42 100644
>> --- a/libavcodec/mjpegdec.c
>> +++ b/libavcodec/mjpegdec.c
>> @@ -36,6 +36,7 @@
>> #include "avcodec.h"
>> #include "blockdsp.h"
>> #include "copy_block.h"
>> +#include "hwaccel.h"
>> #include "idctdsp.h"
>> #include "internal.h"
>> #include "jpegtables.h"
>> @@ -147,6 +148,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
>> s->org_height = avctx->coded_height;
>> avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
>> avctx->colorspace = AVCOL_SPC_BT470BG;
>> + s->hwaccel_pix_fmt = s->hwaccel_sw_pix_fmt = AV_PIX_FMT_NONE;
>>
>> if ((ret = build_basic_mjpeg_vlc(s)) < 0)
>> return ret;
>> @@ -279,6 +281,11 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
>> code_max + 1, 0, 0)) < 0)
>> return ret;
>> }
>> +
>> + for (i = 0; i < 16; i++)
>> + s->raw_huffman_lengths[class][index][i] = bits_table[i + 1];
>> + for (i = 0; i < 256; i++)
>> + s->raw_huffman_values[class][index][i] = val_table[i];
>> }
>> return 0;
>> }
>> @@ -636,6 +643,26 @@ unk_pixfmt:
>> return AVERROR_BUG;
>> }
>>
>> + if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
>> + s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
>> + if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ422P)
>> + s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
>> +
> Maybe need to give a comments in the code for this workaround, not just
> in the commit message.
This hack is not intended to be applied. The note above after the commit message is inviting comment on what to actually do.
- Mark
More information about the ffmpeg-devel
mailing list