summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2015-11-07 12:11:57 -0500
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2015-11-07 12:12:46 -0500
commit2a7aaeb3da634cb6f5caf4387a8d55209361f3f3 (patch)
tree2bfda1421aa87654338f595a9b44febe6a5349c4
parent2d94a1cbccf517732b3440ae09672959a84a0fe0 (diff)
avviddec: Don't fallback on allocation failure
Allocation should keep working, falling back causes the stride to change which is not supported in direct rendering. https://bugzilla.gnome.org/show_bug.cgi?id=756028
-rw-r--r--ext/libav/gstavviddec.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c
index 292490d..5269b06 100644
--- a/ext/libav/gstavviddec.c
+++ b/ext/libav/gstavviddec.c
@@ -815,7 +815,7 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture,
/* Fill avpicture */
if (!gst_video_frame_map (&dframe->vframe, &ffmpegdec->pool_info,
dframe->buffer, GST_MAP_READWRITE))
- goto invalid_frame;
+ goto map_failed;
dframe->mapped = TRUE;
for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
@@ -850,30 +850,13 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture,
return 0;
- /* fallbacks */
no_dr:
{
- GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
- goto fallback;
- }
-alloc_failed:
- {
- /* alloc default buffer when we can't get one from downstream */
- GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
- goto fallback;
- }
-invalid_frame:
- {
- /* alloc default buffer when we can't get one from downstream */
- GST_LOG_OBJECT (ffmpegdec, "failed to map frame, fallback alloc");
- gst_buffer_replace (&dframe->buffer, NULL);
- goto fallback;
- }
-fallback:
- {
int c;
int ret = avcodec_default_get_buffer2 (context, picture, flags);
+ GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
+
for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
ffmpegdec->stride[c] = picture->linesize[c];
}
@@ -893,6 +876,21 @@ fallback:
return ret;
}
+alloc_failed:
+ {
+ GST_ELEMENT_ERROR (ffmpegdec, RESOURCE, FAILED,
+ ("Unable to allocate memory"),
+ ("The downstream pool failed to allocated buffer."));
+ return -1;
+ }
+map_failed:
+ {
+ GST_ELEMENT_ERROR (ffmpegdec, RESOURCE, OPEN_READ_WRITE,
+ ("Cannot access memory for read and write operation."),
+ ("The video memory allocated from downstream pool could not mapped for"
+ "read and write."));
+ return -1;
+ }
duplicate_frame:
{
GST_WARNING_OBJECT (ffmpegdec, "already alloc'ed output buffer for frame");
@@ -1227,7 +1225,7 @@ get_output_buffer (GstFFMpegVidDec * ffmpegdec, GstVideoCodecFrame * frame)
info = &ffmpegdec->output_state->info;
if (!gst_video_frame_map (&vframe, info, frame->output_buffer,
GST_MAP_READ | GST_MAP_WRITE))
- goto alloc_failed;
+ goto map_failed;
for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
if (c < GST_VIDEO_INFO_N_PLANES (info)) {
@@ -1255,7 +1253,17 @@ get_output_buffer (GstFFMpegVidDec * ffmpegdec, GstVideoCodecFrame * frame)
/* special cases */
alloc_failed:
{
- GST_DEBUG_OBJECT (ffmpegdec, "allocation failed");
+ GST_ELEMENT_ERROR (ffmpegdec, RESOURCE, FAILED,
+ ("Unable to allocate memory"),
+ ("The downstream pool failed to allocated buffer."));
+ return ret;
+ }
+map_failed:
+ {
+ GST_ELEMENT_ERROR (ffmpegdec, RESOURCE, OPEN_READ_WRITE,
+ ("Cannot access memory for read and write operation."),
+ ("The video memory allocated from downstream pool could not mapped for"
+ "read and write."));
return ret;
}
not_negotiated: