mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-22 15:23:11 +00:00
Support switching field order when decoding frwu.
The binary encoder has a "switch field order" setting that moves one line from the top to the bottom of the frame. Fixes ticket #966.
This commit is contained in:
parent
b5b9686615
commit
d643dd5c55
@ -22,6 +22,12 @@
|
|||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
AVClass *av_class;
|
||||||
|
int change_field_order;
|
||||||
|
} FRWUContext;
|
||||||
|
|
||||||
static av_cold int decode_init(AVCodecContext *avctx)
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
@ -41,6 +47,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||||
AVPacket *avpkt)
|
AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
|
FRWUContext *s = avctx->priv_data;
|
||||||
int field, ret;
|
int field, ret;
|
||||||
AVFrame *pic = avctx->coded_frame;
|
AVFrame *pic = avctx->coded_frame;
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
@ -84,9 +91,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf));
|
av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf));
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (field)
|
if (field ^ s->change_field_order) {
|
||||||
dst += pic->linesize[0];
|
dst += pic->linesize[0];
|
||||||
|
} else if (s->change_field_order) {
|
||||||
|
dst += 2 * pic->linesize[0];
|
||||||
|
}
|
||||||
for (i = 0; i < field_h; i++) {
|
for (i = 0; i < field_h; i++) {
|
||||||
|
if (s->change_field_order && field && i == field_h - 1)
|
||||||
|
dst = pic->data[0];
|
||||||
memcpy(dst, buf, avctx->width * 2);
|
memcpy(dst, buf, avctx->width * 2);
|
||||||
buf += avctx->width * 2;
|
buf += avctx->width * 2;
|
||||||
dst += pic->linesize[0] << 1;
|
dst += pic->linesize[0] << 1;
|
||||||
@ -110,13 +122,28 @@ static av_cold int decode_close(AVCodecContext *avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const AVOption frwu_options[] = {
|
||||||
|
{"change_field_order", "Change field order", offsetof(FRWUContext, change_field_order), FF_OPT_TYPE_INT,
|
||||||
|
{.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM},
|
||||||
|
{NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const AVClass frwu_class = {
|
||||||
|
.class_name = "frwu Decoder",
|
||||||
|
.item_name = av_default_item_name,
|
||||||
|
.option = frwu_options,
|
||||||
|
.version = LIBAVUTIL_VERSION_INT,
|
||||||
|
};
|
||||||
|
|
||||||
AVCodec ff_frwu_decoder = {
|
AVCodec ff_frwu_decoder = {
|
||||||
.name = "frwu",
|
.name = "frwu",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_FRWU,
|
.id = AV_CODEC_ID_FRWU,
|
||||||
|
.priv_data_size = sizeof(FRWUContext),
|
||||||
.init = decode_init,
|
.init = decode_init,
|
||||||
.close = decode_close,
|
.close = decode_close,
|
||||||
.decode = decode_frame,
|
.decode = decode_frame,
|
||||||
.capabilities = CODEC_CAP_DR1,
|
.capabilities = CODEC_CAP_DR1,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"),
|
.long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"),
|
||||||
|
.priv_class = &frwu_class,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user