Commit 40e5d31b authored by Gwenole Beauchesne's avatar Gwenole Beauchesne Committed by Michael Niedermayer

More approved hunks for VAAPI & our new and cleaner hwaccel API.

patch by Gwenole Beauchesne gbeauchesne splitted-desktop com

Originally committed as revision 17540 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent c269cf68
...@@ -2315,6 +2315,13 @@ typedef struct AVCodecContext { ...@@ -2315,6 +2315,13 @@ typedef struct AVCodecContext {
* - decoding: unused. * - decoding: unused.
*/ */
float rc_min_vbv_overflow_use; float rc_min_vbv_overflow_use;
/**
* Hardware accelerator in use
* - encoding: unused.
* - decoding: Set by libavcodec
*/
struct AVHWAccel *hwaccel;
} AVCodecContext; } AVCodecContext;
/** /**
...@@ -2359,6 +2366,87 @@ typedef struct AVCodec { ...@@ -2359,6 +2366,87 @@ typedef struct AVCodec {
const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
} AVCodec; } AVCodec;
/**
* AVHWAccel.
*/
typedef struct AVHWAccel {
/**
* Name of the hardware accelerated codec.
* The name is globally unique among encoders and among decoders (but an
* encoder and a decoder can share the same name).
*/
const char *name;
/**
* Type of codec implemented by the hardware accelerator.
*
* See CODEC_TYPE_xxx
*/
enum CodecType type;
/**
* Codec implemented by the hardware accelerator.
*
* See CODEC_ID_xxx
*/
enum CodecID id;
/**
* Supported pixel format.
*
* Only hardware accelerated formats are supported here.
*/
enum PixelFormat pix_fmt;
/**
* Hardware accelerated codec capabilities.
* see FF_HWACCEL_CODEC_CAP_*
*/
int capabilities;
struct AVHWAccel *next;
/**
* Called at the beginning of each frame or field picture.
*
* Meaningful frame information (codec specific) is guaranteed to
* be parsed at this point. This function is mandatory.
*
* Note that \p buf can be NULL along with \p buf_size set to 0.
* Otherwise, this means the whole frame is available at this point.
*
* @param avctx the codec context
* @param buf the frame data buffer base
* @param buf_size the size of the frame in bytes
* @return zero if successful, a negative value otherwise
*/
int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
/**
* Callback for each slice.
*
* Meaningful slice information (codec specific) is guaranteed to
* be parsed at this point. This function is mandatory.
*
* @param avctx the codec context
* @param buf the slice data buffer base
* @param buf_size the size of the slice in bytes
* @return zero if successful, a negative value otherwise
*/
int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
/**
* Called at the end of each frame or field picture.
*
* The whole picture is parsed at this point and can now be sent
* to the hardware accelerator. This function is mandatory.
*
* @param avctx the codec context
* @return zero if successful, a negative value otherwise
*/
int (*end_frame)(AVCodecContext *avctx);
} AVHWAccel;
/** /**
* four components are given, that's all. * four components are given, that's all.
* the last component is alpha * the last component is alpha
...@@ -3196,4 +3284,16 @@ int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); ...@@ -3196,4 +3284,16 @@ int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
#define AVERROR_EOF AVERROR(EPIPE) /**< End of file. */ #define AVERROR_EOF AVERROR(EPIPE) /**< End of file. */
#define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */ #define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */
/**
* Registers the hardware accelerator \p hwaccel.
*/
void av_register_hwaccel(AVHWAccel *hwaccel);
/**
* If hwaccel is NULL, returns the first registered hardware accelerator,
* if hwaccel is non-NULL, returns the next registered hardware accelerator
* after hwaccel, or NULL if hwaccel is the last one.
*/
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
#endif /* AVCODEC_AVCODEC_H */ #endif /* AVCODEC_AVCODEC_H */
...@@ -680,6 +680,7 @@ void ff_er_frame_end(MpegEncContext *s){ ...@@ -680,6 +680,7 @@ void ff_er_frame_end(MpegEncContext *s){
Picture *pic= s->current_picture_ptr; Picture *pic= s->current_picture_ptr;
if(!s->error_recognition || s->error_count==0 || s->avctx->lowres || if(!s->error_recognition || s->error_count==0 || s->avctx->lowres ||
s->avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return; s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* H.263 decoder. * H.263 decoder.
*/ */
#include "internal.h"
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
#include "mpegvideo.h" #include "mpegvideo.h"
...@@ -159,6 +160,9 @@ static int decode_slice(MpegEncContext *s){ ...@@ -159,6 +160,9 @@ static int decode_slice(MpegEncContext *s){
ff_set_qscale(s, s->qscale); ff_set_qscale(s, s->qscale);
if (s->avctx->hwaccel)
return 0;
if(s->partitioned_frame){ if(s->partitioned_frame){
const int qscale= s->qscale; const int qscale= s->qscale;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at> * @author Michael Niedermayer <michaelni@gmx.at>
*/ */
#include "internal.h"
#include "dsputil.h" #include "dsputil.h"
#include "avcodec.h" #include "avcodec.h"
#include "mpegvideo.h" #include "mpegvideo.h"
...@@ -7356,6 +7357,8 @@ static void execute_decode_slices(H264Context *h, int context_count){ ...@@ -7356,6 +7357,8 @@ static void execute_decode_slices(H264Context *h, int context_count){
H264Context *hx; H264Context *hx;
int i; int i;
if (s->avctx->hwaccel)
return;
if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
return; return;
if(context_count == 1) { if(context_count == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment