mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
Merge commit 'ffe04c330335add4c6d70ab0bb98e6b3f4f7abfa'
* commit 'ffe04c330335add4c6d70ab0bb98e6b3f4f7abfa': libxvid: use the AVFrame API properly. pcxenc: use the AVFrame API properly. roqvideo: remove unused variables libschroedingerenc: use the AVFrame API properly. Conflicts: libavcodec/pcxenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
f4f7888bab
@ -47,9 +47,6 @@ typedef struct SchroEncoderParams {
|
|||||||
/** Schroedinger frame format */
|
/** Schroedinger frame format */
|
||||||
SchroFrameFormat frame_format;
|
SchroFrameFormat frame_format;
|
||||||
|
|
||||||
/** frame being encoded */
|
|
||||||
AVFrame picture;
|
|
||||||
|
|
||||||
/** frame size */
|
/** frame size */
|
||||||
int frame_size;
|
int frame_size;
|
||||||
|
|
||||||
@ -162,7 +159,9 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
|
|||||||
avctx->width,
|
avctx->width,
|
||||||
avctx->height);
|
avctx->height);
|
||||||
|
|
||||||
avctx->coded_frame = &p_schro_params->picture;
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (!avctx->gop_size) {
|
if (!avctx->gop_size) {
|
||||||
schro_encoder_setting_set_double(p_schro_params->encoder,
|
schro_encoder_setting_set_double(p_schro_params->encoder,
|
||||||
@ -427,6 +426,8 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
|
|||||||
/* Free the video format structure. */
|
/* Free the video format structure. */
|
||||||
av_freep(&p_schro_params->format);
|
av_freep(&p_schro_params->format);
|
||||||
|
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ struct xvid_context {
|
|||||||
int me_flags; /**< Motion Estimation flags */
|
int me_flags; /**< Motion Estimation flags */
|
||||||
int qscale; /**< Do we use constant scale? */
|
int qscale; /**< Do we use constant scale? */
|
||||||
int quicktime_format; /**< Are we in a QT-based format? */
|
int quicktime_format; /**< Are we in a QT-based format? */
|
||||||
AVFrame encoded_picture; /**< Encoded frame information */
|
|
||||||
char *twopassbuffer; /**< Character buffer for two-pass */
|
char *twopassbuffer; /**< Character buffer for two-pass */
|
||||||
char *old_twopassbuffer; /**< Old character buffer (two-pass) */
|
char *old_twopassbuffer; /**< Old character buffer (two-pass) */
|
||||||
char *twopassfile; /**< second pass temp file name */
|
char *twopassfile; /**< second pass temp file name */
|
||||||
@ -651,7 +650,9 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
x->encoder_handle = xvid_enc_create.handle;
|
x->encoder_handle = xvid_enc_create.handle;
|
||||||
avctx->coded_frame = &x->encoded_picture;
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
@ -665,7 +666,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
int xerr, i, ret, user_packet = !!pkt->data;
|
int xerr, i, ret, user_packet = !!pkt->data;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
struct xvid_context *x = avctx->priv_data;
|
struct xvid_context *x = avctx->priv_data;
|
||||||
AVFrame *p = &x->encoded_picture;
|
AVFrame *p = avctx->coded_frame;
|
||||||
int mb_width = (avctx->width + 15) / 16;
|
int mb_width = (avctx->width + 15) / 16;
|
||||||
int mb_height = (avctx->height + 15) / 16;
|
int mb_height = (avctx->height + 15) / 16;
|
||||||
|
|
||||||
@ -678,7 +679,6 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
/* Start setting up the frame */
|
/* Start setting up the frame */
|
||||||
xvid_enc_frame.version = XVID_VERSION;
|
xvid_enc_frame.version = XVID_VERSION;
|
||||||
xvid_enc_stats.version = XVID_VERSION;
|
xvid_enc_stats.version = XVID_VERSION;
|
||||||
*p = *picture;
|
|
||||||
|
|
||||||
/* Let Xvid know where to put the frame. */
|
/* Let Xvid know where to put the frame. */
|
||||||
xvid_enc_frame.bitstream = pkt->data;
|
xvid_enc_frame.bitstream = pkt->data;
|
||||||
|
@ -33,6 +33,24 @@
|
|||||||
|
|
||||||
static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
|
static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
|
||||||
|
|
||||||
|
static av_cold int pcx_encode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int pcx_encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCX run-length encoder
|
* PCX run-length encoder
|
||||||
* @param dst output buffer
|
* @param dst output buffer
|
||||||
@ -86,7 +104,6 @@ static int pcx_rle_encode( uint8_t *dst, int dst_size,
|
|||||||
static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
const AVFrame *frame, int *got_packet)
|
const AVFrame *frame, int *got_packet)
|
||||||
{
|
{
|
||||||
AVFrame *const pict = (AVFrame *) frame;
|
|
||||||
const uint8_t *buf_end;
|
const uint8_t *buf_end;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
@ -95,9 +112,6 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
uint32_t palette256[256];
|
uint32_t palette256[256];
|
||||||
const uint8_t *src;
|
const uint8_t *src;
|
||||||
|
|
||||||
pict->pict_type = AV_PICTURE_TYPE_I;
|
|
||||||
pict->key_frame = 1;
|
|
||||||
|
|
||||||
if (avctx->width > 65535 || avctx->height > 65535) {
|
if (avctx->width > 65535 || avctx->height > 65535) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "image dimensions do not fit in 16 bits\n");
|
av_log(avctx, AV_LOG_ERROR, "image dimensions do not fit in 16 bits\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -121,7 +135,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
case AV_PIX_FMT_PAL8:
|
case AV_PIX_FMT_PAL8:
|
||||||
bpp = 8;
|
bpp = 8;
|
||||||
nplanes = 1;
|
nplanes = 1;
|
||||||
pal = (uint32_t *)pict->data[1];
|
pal = (uint32_t *)frame->data[1];
|
||||||
break;
|
break;
|
||||||
case AV_PIX_FMT_MONOBLACK:
|
case AV_PIX_FMT_MONOBLACK:
|
||||||
bpp = 1;
|
bpp = 1;
|
||||||
@ -166,7 +180,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
while (buf - pkt->data < 128)
|
while (buf - pkt->data < 128)
|
||||||
*buf++= 0;
|
*buf++= 0;
|
||||||
|
|
||||||
src = pict->data[0];
|
src = frame->data[0];
|
||||||
|
|
||||||
for (y = 0; y < avctx->height; y++) {
|
for (y = 0; y < avctx->height; y++) {
|
||||||
if ((written = pcx_rle_encode(buf, buf_end - buf,
|
if ((written = pcx_rle_encode(buf, buf_end - buf,
|
||||||
@ -175,7 +189,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
buf += written;
|
buf += written;
|
||||||
src += pict->linesize[0];
|
src += frame->linesize[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nplanes == 1 && bpp == 8) {
|
if (nplanes == 1 && bpp == 8) {
|
||||||
@ -201,6 +215,8 @@ AVCodec ff_pcx_encoder = {
|
|||||||
.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
|
.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_PCX,
|
.id = AV_CODEC_ID_PCX,
|
||||||
|
.init = pcx_encode_init,
|
||||||
|
.close = pcx_encode_close,
|
||||||
.encode2 = pcx_encode_frame,
|
.encode2 = pcx_encode_frame,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]){
|
.pix_fmts = (const enum AVPixelFormat[]){
|
||||||
AV_PIX_FMT_RGB24,
|
AV_PIX_FMT_RGB24,
|
||||||
|
@ -44,7 +44,6 @@ struct RoqTempData;
|
|||||||
typedef struct RoqContext {
|
typedef struct RoqContext {
|
||||||
|
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame frames[2];
|
|
||||||
AVFrame *last_frame;
|
AVFrame *last_frame;
|
||||||
AVFrame *current_frame;
|
AVFrame *current_frame;
|
||||||
int first_frame;
|
int first_frame;
|
||||||
|
Loading…
Reference in New Issue
Block a user