nuv: do not rely on get_buffer() initializing the frame.
This commit is contained in:
@@ -149,7 +149,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
AVFrame *picture = data;
|
AVFrame *picture = data;
|
||||||
int orig_size = buf_size;
|
int orig_size = buf_size;
|
||||||
int keyframe;
|
int keyframe;
|
||||||
int result;
|
int result, init_frame = !avctx->frame_number;
|
||||||
enum {
|
enum {
|
||||||
NUV_UNCOMPRESSED = '0',
|
NUV_UNCOMPRESSED = '0',
|
||||||
NUV_RTJPEG = '1',
|
NUV_RTJPEG = '1',
|
||||||
@@ -221,8 +221,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
buf_size -= RTJPEG_HEADER_SIZE;
|
buf_size -= RTJPEG_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyframe && c->pic.data[0])
|
if (keyframe && c->pic.data[0]) {
|
||||||
avctx->release_buffer(avctx, &c->pic);
|
avctx->release_buffer(avctx, &c->pic);
|
||||||
|
init_frame = 1;
|
||||||
|
}
|
||||||
c->pic.reference = 3;
|
c->pic.reference = 3;
|
||||||
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
|
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
|
||||||
FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||||
@@ -231,6 +233,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (init_frame) {
|
||||||
|
memset(c->pic.data[0], 0, avctx->height * c->pic.linesize[0]);
|
||||||
|
memset(c->pic.data[1], 0x80, avctx->height * c->pic.linesize[1] / 2);
|
||||||
|
memset(c->pic.data[2], 0x80, avctx->height * c->pic.linesize[2] / 2);
|
||||||
|
}
|
||||||
|
|
||||||
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||||
c->pic.key_frame = keyframe;
|
c->pic.key_frame = keyframe;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
#tb 0: 1/1000
|
#tb 0: 1/1000
|
||||||
0, 0, 0, 0, 221184, 0xf48c94f6
|
0, 0, 0, 0, 221184, 0xdaf54f83
|
||||||
0, 40, 40, 0, 221184, 0x89b625b2
|
0, 40, 40, 0, 221184, 0xeea3e3b4
|
||||||
0, 60, 60, 0, 221184, 0x37e04714
|
0, 60, 60, 0, 221184, 0x5f1a8525
|
||||||
0, 80, 80, 0, 221184, 0x4f4c5224
|
0, 80, 80, 0, 221184, 0x950bb170
|
||||||
0, 100, 100, 0, 221184, 0x9193c9f1
|
0, 100, 100, 0, 221184, 0x6262e94c
|
||||||
0, 120, 120, 0, 221184, 0x5d1a6197
|
0, 120, 120, 0, 221184, 0x28752197
|
||||||
0, 140, 140, 0, 221184, 0x40cd51e7
|
0, 140, 140, 0, 221184, 0x0c2811e7
|
||||||
0, 160, 160, 0, 221184, 0xb2c1a729
|
0, 160, 160, 0, 221184, 0xb2c1a729
|
||||||
0, 200, 200, 0, 221184, 0x998d6144
|
0, 200, 200, 0, 221184, 0x998d6144
|
||||||
0, 220, 220, 0, 221184, 0xf5d52311
|
0, 220, 220, 0, 221184, 0xf5d52311
|
||||||
|
Reference in New Issue
Block a user