diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c
index c70013b..6e2522f 100644
|
a
|
b
|
|
| 22 | 22 | |
| 23 | 23 | #include "avcodec.h" |
| 24 | 24 | #include "bytestream.h" |
| | 25 | #include "libavutil/opt.h" |
| | 26 | |
| | 27 | typedef struct { |
| | 28 | AVClass *av_class; |
| | 29 | int change_field_order; |
| | 30 | } FRWUContext; |
| 25 | 31 | |
| 26 | 32 | static av_cold int decode_init(AVCodecContext *avctx) |
| 27 | 33 | { |
| … |
… |
static av_cold int decode_init(AVCodecContext *avctx) |
| 41 | 47 | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 42 | 48 | AVPacket *avpkt) |
| 43 | 49 | { |
| | 50 | FRWUContext *s = avctx->priv_data; |
| 44 | 51 | int field, ret; |
| 45 | 52 | AVFrame *pic = avctx->coded_frame; |
| 46 | 53 | const uint8_t *buf = avpkt->data; |
| … |
… |
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 84 | 91 | av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf)); |
| 85 | 92 | return AVERROR_INVALIDDATA; |
| 86 | 93 | } |
| 87 | | if (field) |
| | 94 | if (field ^ s->change_field_order) { |
| 88 | 95 | dst += pic->linesize[0]; |
| | 96 | } else if (s->change_field_order) { |
| | 97 | dst += 2 * pic->linesize[0]; |
| | 98 | } |
| 89 | 99 | for (i = 0; i < field_h; i++) { |
| | 100 | if (s->change_field_order && field && i == field_h - 1) |
| | 101 | dst = pic->data[0]; |
| 90 | 102 | memcpy(dst, buf, avctx->width * 2); |
| 91 | 103 | buf += avctx->width * 2; |
| 92 | 104 | dst += pic->linesize[0] << 1; |
| … |
… |
static av_cold int decode_close(AVCodecContext *avctx) |
| 110 | 122 | return 0; |
| 111 | 123 | } |
| 112 | 124 | |
| | 125 | static const AVOption frwu_options[] = { |
| | 126 | {"change_field_order", "Change frwu field order", offsetof(FRWUContext, change_field_order), FF_OPT_TYPE_INT, |
| | 127 | {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM}, |
| | 128 | {NULL} |
| | 129 | }; |
| | 130 | |
| | 131 | static const AVClass frwu_class = { |
| | 132 | "frwu Decoder", |
| | 133 | av_default_item_name, |
| | 134 | frwu_options, |
| | 135 | LIBAVUTIL_VERSION_INT, |
| | 136 | }; |
| | 137 | |
| 113 | 138 | AVCodec ff_frwu_decoder = { |
| 114 | 139 | .name = "frwu", |
| 115 | 140 | .type = AVMEDIA_TYPE_VIDEO, |
| 116 | 141 | .id = AV_CODEC_ID_FRWU, |
| | 142 | .priv_data_size = sizeof(FRWUContext), |
| 117 | 143 | .init = decode_init, |
| 118 | 144 | .close = decode_close, |
| 119 | 145 | .decode = decode_frame, |
| 120 | 146 | .capabilities = CODEC_CAP_DR1, |
| 121 | 147 | .long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"), |
| | 148 | .priv_class = &frwu_class, |
| 122 | 149 | }; |