* commit '45bde93eef':
  sunrastenc: use the AVFrame API properly.
  targaenc: use the AVFrame API properly.
  tiffenc: use the AVFrame API properly.
  pngenc: use the AVFrame API properly.

Conflicts:
	libavcodec/pngenc.c
	libavcodec/sunrastenc.c
	libavcodec/targaenc.c
	libavcodec/tiffenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-11-17 12:02:09 +01:00
commit 3ea168edeb
4 changed files with 64 additions and 29 deletions

View file

@ -52,7 +52,6 @@ static const uint8_t type_sizes2[14] = {
typedef struct TiffEncoderContext {
AVClass *class; ///< for private options
AVCodecContext *avctx;
AVFrame picture;
int width; ///< picture width
int height; ///< picture height
@ -195,9 +194,9 @@ static int encode_strip(TiffEncoderContext *s, const int8_t *src,
}
}
static void pack_yuv(TiffEncoderContext *s, uint8_t *dst, int lnum)
static void pack_yuv(TiffEncoderContext *s, const AVFrame *p,
uint8_t *dst, int lnum)
{
AVFrame *p = &s->picture;
int i, j, k;
int w = (s->width - 1) / s->subsampling[0] + 1;
uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
@ -223,24 +222,12 @@ static void pack_yuv(TiffEncoderContext *s, uint8_t *dst, int lnum)
}
}
static av_cold int encode_init(AVCodecContext *avctx)
{
TiffEncoderContext *s = avctx->priv_data;
avctx->coded_frame = &s->picture;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
s->avctx = avctx;
return 0;
}
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
TiffEncoderContext *s = avctx->priv_data;
AVFrame *const p = &s->picture;
const AVFrame *const p = pict;
int i;
uint8_t *ptr;
uint8_t *offset;
@ -252,8 +239,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int is_yuv = 0, alpha = 0;
int shift_h, shift_v;
*p = *pict;
s->width = avctx->width;
s->height = avctx->height;
s->subsampling[0] = 1;
@ -373,7 +358,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
zn = 0;
for (j = 0; j < s->rps; j++) {
if (is_yuv) {
pack_yuv(s, s->yuv_line, j);
pack_yuv(s, p, s->yuv_line, j);
memcpy(zbuf + zn, s->yuv_line, bytes_per_row);
j += s->subsampling[1] - 1;
} else
@ -409,7 +394,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->strip_offsets[i / s->rps] = ptr - pkt->data;
}
if (is_yuv) {
pack_yuv(s, s->yuv_line, i);
pack_yuv(s, p, s->yuv_line, i);
ret = encode_strip(s, s->yuv_line, ptr, bytes_per_row, s->compr);
i += s->subsampling[1] - 1;
} else
@ -497,10 +482,26 @@ fail:
return ret < 0 ? ret : 0;
}
static av_cold int encode_init(AVCodecContext *avctx)
{
TiffEncoderContext *s = avctx->priv_data;
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
s->avctx = avctx;
return 0;
}
static av_cold int encode_close(AVCodecContext *avctx)
{
TiffEncoderContext *s = avctx->priv_data;
av_frame_free(&avctx->coded_frame);
av_freep(&s->strip_sizes);
av_freep(&s->strip_offsets);
av_freep(&s->yuv_line);
@ -536,8 +537,8 @@ AVCodec ff_tiff_encoder = {
.id = AV_CODEC_ID_TIFF,
.priv_data_size = sizeof(TiffEncoderContext),
.init = encode_init,
.encode2 = encode_frame,
.close = encode_close,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_PAL8, AV_PIX_FMT_GRAY8,
AV_PIX_FMT_GRAY8A, AV_PIX_FMT_GRAY16LE,