History

hwaccel: Support specific frame allocators

It would reduce the boilerplate code users have to write.

Luca Barbato committed 12 years ago

Commit ebc29511 parent a871ef02 files · +12 −0Browse files

Unified · Split

2 files
  1. libavcodec/avcodec.h +5 −0
  2. libavcodec/utils.c +7 −0
libavcodec/avcodec.h+5−0
@@ -2946,6 +2946,11 @@ typedef struct AVHWAccel { · 2945 unmodified lines
29462946 */
29472947 struct AVHWAccel *next;
29482948
2949+ /**
2950+ * Allocate a custom buffer
2951+ */
2952+ int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
2953+
29492954 /**
29502955 * Called at the beginning of each frame or field picture.
29512956 *
libavcodec/utils.c+7−0
@@ -604,6 +604,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) · 603 unmodified lines
604604
605605 int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
606606 {
607+ const AVHWAccel *hwaccel = avctx->hwaccel;
607608 int override_dimensions = 1;
608609 int ret;
609610
@@ -657,6 +658,11 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 47 unmodified lines
657658 if (ret < 0)
658659 return ret;
659660
661+ if (hwaccel && hwaccel->alloc_frame) {
662+ ret = hwaccel->alloc_frame(avctx, frame);
663+ goto end;
664+ }
665+
660666 #if FF_API_GET_BUFFER
661667 FF_DISABLE_DEPRECATION_WARNINGS
662668 /*
@@ -775,6 +781,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 112 unmodified lines
775781
776782 ret = avctx->get_buffer2(avctx, frame, flags);
777783
784+end:
778785 if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) {
779786 frame->width = avctx->width;
780787 frame->height = avctx->height;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t