mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avcodec/libxvid: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
039ea9ec7b
commit
2101b99777
@ -684,10 +684,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
/* Encode a dummy frame to get the extradata immediately */
|
/* Encode a dummy frame to get the extradata immediately */
|
||||||
if (x->quicktime_format) {
|
if (x->quicktime_format) {
|
||||||
AVFrame *picture;
|
AVFrame *picture;
|
||||||
AVPacket packet = {0};
|
AVPacket *packet;
|
||||||
int size, got_packet, ret;
|
int size, got_packet, ret;
|
||||||
|
|
||||||
av_init_packet(&packet);
|
packet = av_packet_alloc();
|
||||||
|
if (!packet)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
picture = av_frame_alloc();
|
picture = av_frame_alloc();
|
||||||
if (!picture)
|
if (!picture)
|
||||||
@ -695,6 +697,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
|
|
||||||
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
|
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
|
||||||
if( xerr ) {
|
if( xerr ) {
|
||||||
|
av_packet_free(&packet);
|
||||||
av_frame_free(&picture);
|
av_frame_free(&picture);
|
||||||
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
|
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
@ -703,6 +706,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
size = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
|
size = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
|
||||||
picture->data[0] = av_malloc(size + size / 2);
|
picture->data[0] = av_malloc(size + size / 2);
|
||||||
if (!picture->data[0]) {
|
if (!picture->data[0]) {
|
||||||
|
av_packet_free(&packet);
|
||||||
av_frame_free(&picture);
|
av_frame_free(&picture);
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
@ -710,9 +714,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
picture->data[2] = picture->data[1] + size / 4;
|
picture->data[2] = picture->data[1] + size / 4;
|
||||||
memset(picture->data[0], 0, size);
|
memset(picture->data[0], 0, size);
|
||||||
memset(picture->data[1], 128, size / 2);
|
memset(picture->data[1], 128, size / 2);
|
||||||
ret = xvid_encode_frame(avctx, &packet, picture, &got_packet);
|
ret = xvid_encode_frame(avctx, packet, picture, &got_packet);
|
||||||
if (!ret && got_packet)
|
av_packet_free(&packet);
|
||||||
av_packet_unref(&packet);
|
|
||||||
av_free(picture->data[0]);
|
av_free(picture->data[0]);
|
||||||
av_frame_free(&picture);
|
av_frame_free(&picture);
|
||||||
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
|
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user