examples/muxing: simplify alloc_picture()
Use avpicture_alloc() high level function.
This commit is contained in:
parent
e776ee8f29
commit
66747a6160
@ -245,21 +245,9 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id)
|
|||||||
|
|
||||||
static AVFrame *alloc_picture(enum PixelFormat pix_fmt, int width, int height)
|
static AVFrame *alloc_picture(enum PixelFormat pix_fmt, int width, int height)
|
||||||
{
|
{
|
||||||
AVFrame *picture;
|
AVFrame *picture = avcodec_alloc_frame();
|
||||||
uint8_t *picture_buf;
|
if (!picture || avpicture_alloc((AVPicture *)picture, pix_fmt, width, height) < 0)
|
||||||
int size;
|
av_freep(&picture);
|
||||||
|
|
||||||
picture = avcodec_alloc_frame();
|
|
||||||
if (!picture)
|
|
||||||
return NULL;
|
|
||||||
size = avpicture_get_size(pix_fmt, width, height);
|
|
||||||
picture_buf = av_malloc(size);
|
|
||||||
if (!picture_buf) {
|
|
||||||
av_free(picture);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
avpicture_fill((AVPicture *)picture, picture_buf,
|
|
||||||
pix_fmt, width, height);
|
|
||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user