mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 20:37:04 +00:00
huffyuv: use the AVFrame API properly.
This commit is contained in:
parent
ffe04c3303
commit
14b35bf065
@ -78,7 +78,6 @@ typedef struct HYuvContext {
|
|||||||
uint32_t bits[3][256];
|
uint32_t bits[3][256];
|
||||||
uint32_t pix_bgr_map[1<<VLC_BITS];
|
uint32_t pix_bgr_map[1<<VLC_BITS];
|
||||||
VLC vlc[6]; //Y,U,V,YY,YU,YV
|
VLC vlc[6]; //Y,U,V,YY,YU,YV
|
||||||
AVFrame picture;
|
|
||||||
uint8_t *bitstream_buffer;
|
uint8_t *bitstream_buffer;
|
||||||
unsigned int bitstream_buffer_size;
|
unsigned int bitstream_buffer_size;
|
||||||
DSPContext dsp;
|
DSPContext dsp;
|
||||||
|
@ -151,7 +151,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
|
avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
|
||||||
s->version = 2;
|
s->version = 2;
|
||||||
|
|
||||||
avctx->coded_frame = &s->picture;
|
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;
|
||||||
|
|
||||||
switch (avctx->pix_fmt) {
|
switch (avctx->pix_fmt) {
|
||||||
case AV_PIX_FMT_YUV420P:
|
case AV_PIX_FMT_YUV420P:
|
||||||
@ -438,7 +443,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
const int fake_ystride = s->interlaced ? pict->linesize[0]*2 : pict->linesize[0];
|
const int fake_ystride = s->interlaced ? pict->linesize[0]*2 : pict->linesize[0];
|
||||||
const int fake_ustride = s->interlaced ? pict->linesize[1]*2 : pict->linesize[1];
|
const int fake_ustride = s->interlaced ? pict->linesize[1]*2 : pict->linesize[1];
|
||||||
const int fake_vstride = s->interlaced ? pict->linesize[2]*2 : pict->linesize[2];
|
const int fake_vstride = s->interlaced ? pict->linesize[2]*2 : pict->linesize[2];
|
||||||
AVFrame * const p = &s->picture;
|
const AVFrame * const p = pict;
|
||||||
int i, j, size = 0, ret;
|
int i, j, size = 0, ret;
|
||||||
|
|
||||||
if (!pkt->data &&
|
if (!pkt->data &&
|
||||||
@ -447,10 +452,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = *pict;
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
|
||||||
p->key_frame = 1;
|
|
||||||
|
|
||||||
if (s->context) {
|
if (s->context) {
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
ff_huff_gen_len_table(s->len[i], s->stats[i]);
|
ff_huff_gen_len_table(s->len[i], s->stats[i]);
|
||||||
@ -676,6 +677,8 @@ static av_cold int encode_end(AVCodecContext *avctx)
|
|||||||
av_freep(&avctx->extradata);
|
av_freep(&avctx->extradata);
|
||||||
av_freep(&avctx->stats_out);
|
av_freep(&avctx->stats_out);
|
||||||
|
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user