summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-11 23:28:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-05-11 23:28:40 +0200
commitf2f99f07a5f1f74a91503cc6c3730c06498cee43 (patch)
treef8a6fd207cf7c004e53d0f19ffa1ff0b7c25a5f1
parentd93cf093f840b9a28481c73d7e421f469f2ca4e7 (diff)
parent5c1d7246cd65dc4db1b6dc36e29ce39fc1068f3f (diff)
Merge commit '5c1d7246cd65dc4db1b6dc36e29ce39fc1068f3f'
* commit '5c1d7246cd65dc4db1b6dc36e29ce39fc1068f3f': lavc: set AVCodecContext.hwaccel in ff_get_format() Conflicts: libavcodec/mpeg12dec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/h263dec.c1
-rw-r--r--libavcodec/h264_slice.c2
-rw-r--r--libavcodec/internal.h9
-rw-r--r--libavcodec/mpeg12dec.c1
-rw-r--r--libavcodec/utils.c48
-rw-r--r--libavcodec/vc1dec.c1
6 files changed, 33 insertions, 29 deletions
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 0eba2f9141..792c3ed365 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -112,7 +112,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
s->codec_id = avctx->codec->id;
- avctx->hwaccel = ff_find_hwaccel(avctx);
if (avctx->stream_codec_tag == AV_RL32("l263") && avctx->extradata_size == 56 && avctx->extradata[0] == 1)
s->ehc_mode = 1;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c70814f0c3..7d28ba2a73 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1161,8 +1161,6 @@ static int h264_slice_header_init(H264Context *h, int reinit)
h->sps.num_units_in_tick, den, 1 << 30);
}
- h->avctx->hwaccel = ff_find_hwaccel(h->avctx);
-
if (reinit)
ff_h264_free_tables(h, 0);
h->first_field = 0;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index abe9fb93b9..8e6ed291f2 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -132,15 +132,6 @@ struct AVCodecDefault {
extern const uint8_t ff_log2_run[41];
/**
- * Return the hardware accelerated codec for codec codec_id and
- * pixel format pix_fmt.
- *
- * @param avctx The codec context containing the codec_id and pixel format.
- * @return the hardware accelerated codec, or NULL if none was found.
- */
-AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx);
-
-/**
* Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
* If there is no such matching pair then size is returned.
*/
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 98a732f111..f77fc6e1a8 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1231,7 +1231,6 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
{
- avctx->hwaccel = ff_find_hwaccel(avctx);
// until then pix_fmt may be changed right after codec init
if (avctx->hwaccel || uses_vdpau(avctx))
if (avctx->idct_algo == FF_IDCT_AUTO)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index f8fa3590e4..04ca363610 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1117,9 +1117,41 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en
return fmt[0];
}
+static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
+ enum AVPixelFormat pix_fmt)
+{
+ AVHWAccel *hwaccel = NULL;
+
+ while ((hwaccel = av_hwaccel_next(hwaccel)))
+ if (hwaccel->id == codec_id
+ && hwaccel->pix_fmt == pix_fmt)
+ return hwaccel;
+ return NULL;
+}
+
+
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
{
- return avctx->get_format(avctx, fmt);
+ const AVPixFmtDescriptor *desc;
+ enum AVPixelFormat ret = avctx->get_format(avctx, fmt);
+
+ desc = av_pix_fmt_desc_get(ret);
+ if (!desc)
+ return AV_PIX_FMT_NONE;
+
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+ avctx->hwaccel = find_hwaccel(avctx->codec_id, ret);
+ if (!avctx->hwaccel) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Could not find an AVHWAccel for the pixel format: %s",
+ desc->name);
+ return AV_PIX_FMT_NONE;
+ }
+ } else {
+ avctx->hwaccel = NULL;
+ }
+
+ return ret;
}
#if FF_API_AVFRAME_LAVC
@@ -3314,20 +3346,6 @@ AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
return hwaccel ? hwaccel->next : first_hwaccel;
}
-AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx)
-{
- enum AVCodecID codec_id = avctx->codec->id;
- enum AVPixelFormat pix_fmt = avctx->pix_fmt;
-
- AVHWAccel *hwaccel = NULL;
-
- while ((hwaccel = av_hwaccel_next(hwaccel)))
- if (hwaccel->id == codec_id
- && hwaccel->pix_fmt == pix_fmt)
- return hwaccel;
- return NULL;
-}
-
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
{
if (lockmgr_cb) {
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index be6a3b8a9d..c53c594bbe 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5609,7 +5609,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
- avctx->hwaccel = ff_find_hwaccel(avctx);
v->s.avctx = avctx;
if ((ret = ff_vc1_init_common(v)) < 0)