Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
63c690ad
Commit
63c690ad
authored
Nov 23, 2017
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vaapi: Add MJPEG decode hwaccel
parent
99ab0a13
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
173 additions
and
2 deletions
+173
-2
Changelog
Changelog
+1
-1
configure
configure
+2
-0
Makefile
libavcodec/Makefile
+1
-0
hwaccels.h
libavcodec/hwaccels.h
+1
-0
mjpegdec.c
libavcodec/mjpegdec.c
+6
-0
vaapi_decode.c
libavcodec/vaapi_decode.c
+2
-0
vaapi_mjpeg.c
libavcodec/vaapi_mjpeg.c
+159
-0
version.h
libavcodec/version.h
+1
-1
No files found.
Changelog
View file @
63c690ad
...
...
@@ -21,7 +21,7 @@ version <next>:
- video mix filter
- video normalize filter
- audio lv2 wrapper filter
- VAAPI VP8 decoding
- VAAPI
MJPEG and
VP8 decoding
- AMD AMF H.264 and HEVC encoders
- video fillborders filter
- video setrange filter
...
...
configure
View file @
63c690ad
...
...
@@ -2714,6 +2714,8 @@ hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
hevc_vdpau_hwaccel_select
=
"hevc_decoder"
hevc_videotoolbox_hwaccel_deps
=
"videotoolbox"
hevc_videotoolbox_hwaccel_select
=
"hevc_decoder"
mjpeg_vaapi_hwaccel_deps
=
"vaapi"
mjpeg_vaapi_hwaccel_select
=
"mjpeg_decoder"
mpeg_xvmc_hwaccel_deps
=
"xvmc"
mpeg_xvmc_hwaccel_select
=
"mpeg2video_decoder"
mpeg1_nvdec_hwaccel_deps
=
"nvdec"
...
...
libavcodec/Makefile
View file @
63c690ad
...
...
@@ -854,6 +854,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
OBJS-$(CONFIG_HEVC_QSV_HWACCEL)
+=
qsvdec_h2645.o
OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL)
+=
vaapi_hevc.o
OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL)
+=
vdpau_hevc.o
OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)
+=
vaapi_mjpeg.o
OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)
+=
nvdec_mpeg12.o
OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)
+=
vdpau_mpeg12.o
OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL)
+=
videotoolbox.o
...
...
libavcodec/hwaccels.h
View file @
63c690ad
...
...
@@ -37,6 +37,7 @@ extern const AVHWAccel ff_hevc_nvdec_hwaccel;
extern
const
AVHWAccel
ff_hevc_vaapi_hwaccel
;
extern
const
AVHWAccel
ff_hevc_vdpau_hwaccel
;
extern
const
AVHWAccel
ff_hevc_videotoolbox_hwaccel
;
extern
const
AVHWAccel
ff_mjpeg_vaapi_hwaccel
;
extern
const
AVHWAccel
ff_mpeg1_nvdec_hwaccel
;
extern
const
AVHWAccel
ff_mpeg1_vdpau_hwaccel
;
extern
const
AVHWAccel
ff_mpeg1_videotoolbox_hwaccel
;
...
...
libavcodec/mjpegdec.c
View file @
63c690ad
...
...
@@ -650,6 +650,9 @@ unk_pixfmt:
s
->
avctx
->
pix_fmt
=
s
->
hwaccel_pix_fmt
;
}
else
{
enum
AVPixelFormat
pix_fmts
[]
=
{
#if CONFIG_MJPEG_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI
,
#endif
s
->
avctx
->
pix_fmt
,
AV_PIX_FMT_NONE
,
};
...
...
@@ -2777,6 +2780,9 @@ AVCodec ff_mjpeg_decoder = {
.
caps_internal
=
FF_CODEC_CAP_INIT_THREADSAFE
|
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
,
.
hw_configs
=
(
const
AVCodecHWConfigInternal
*
[])
{
#if CONFIG_MJPEG_VAAPI_HWACCEL
HWACCEL_VAAPI
(
mjpeg
),
#endif
NULL
},
};
...
...
libavcodec/vaapi_decode.c
View file @
63c690ad
...
...
@@ -379,6 +379,8 @@ static const struct {
MAP
(
HEVC
,
HEVC_MAIN
,
HEVCMain
),
MAP
(
HEVC
,
HEVC_MAIN_10
,
HEVCMain10
),
#endif
MAP
(
MJPEG
,
MJPEG_HUFFMAN_BASELINE_DCT
,
JPEGBaseline
),
MAP
(
WMV3
,
VC1_SIMPLE
,
VC1Simple
),
MAP
(
WMV3
,
VC1_MAIN
,
VC1Main
),
MAP
(
WMV3
,
VC1_COMPLEX
,
VC1Advanced
),
...
...
libavcodec/vaapi_mjpeg.c
0 → 100644
View file @
63c690ad
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <va/va.h>
#include <va/va_dec_jpeg.h>
#include "hwaccel.h"
#include "vaapi_decode.h"
#include "mjpegdec.h"
static
int
vaapi_mjpeg_start_frame
(
AVCodecContext
*
avctx
,
av_unused
const
uint8_t
*
buffer
,
av_unused
uint32_t
size
)
{
const
MJpegDecodeContext
*
s
=
avctx
->
priv_data
;
VAAPIDecodePicture
*
pic
=
s
->
hwaccel_picture_private
;
VAPictureParameterBufferJPEGBaseline
pp
;
int
err
,
i
;
pic
->
output_surface
=
ff_vaapi_get_surface_id
(
s
->
picture_ptr
);
pp
=
(
VAPictureParameterBufferJPEGBaseline
)
{
.
picture_width
=
avctx
->
width
,
.
picture_height
=
avctx
->
height
,
.
num_components
=
s
->
nb_components
,
};
for
(
i
=
0
;
i
<
s
->
nb_components
;
i
++
)
{
pp
.
components
[
i
].
component_id
=
s
->
component_id
[
i
];
pp
.
components
[
i
].
h_sampling_factor
=
s
->
h_count
[
i
];
pp
.
components
[
i
].
v_sampling_factor
=
s
->
v_count
[
i
];
pp
.
components
[
i
].
quantiser_table_selector
=
s
->
quant_index
[
i
];
}
err
=
ff_vaapi_decode_make_param_buffer
(
avctx
,
pic
,
VAPictureParameterBufferType
,
&
pp
,
sizeof
(
pp
));
if
(
err
<
0
)
goto
fail
;
return
0
;
fail:
ff_vaapi_decode_cancel
(
avctx
,
pic
);
return
err
;
}
static
int
vaapi_mjpeg_end_frame
(
AVCodecContext
*
avctx
)
{
const
MJpegDecodeContext
*
s
=
avctx
->
priv_data
;
VAAPIDecodePicture
*
pic
=
s
->
hwaccel_picture_private
;
return
ff_vaapi_decode_issue
(
avctx
,
pic
);
}
static
int
vaapi_mjpeg_decode_slice
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buffer
,
uint32_t
size
)
{
const
MJpegDecodeContext
*
s
=
avctx
->
priv_data
;
VAAPIDecodePicture
*
pic
=
s
->
hwaccel_picture_private
;
VAHuffmanTableBufferJPEGBaseline
huff
;
VAIQMatrixBufferJPEGBaseline
quant
;
VASliceParameterBufferJPEGBaseline
sp
;
int
err
,
i
,
j
;
memset
(
&
huff
,
0
,
sizeof
(
huff
));
for
(
i
=
0
;
i
<
2
;
i
++
)
{
huff
.
load_huffman_table
[
i
]
=
1
;
for
(
j
=
0
;
j
<
16
;
j
++
)
huff
.
huffman_table
[
i
].
num_dc_codes
[
j
]
=
s
->
raw_huffman_lengths
[
0
][
i
][
j
];
for
(
j
=
0
;
j
<
12
;
j
++
)
huff
.
huffman_table
[
i
].
dc_values
[
j
]
=
s
->
raw_huffman_values
[
0
][
i
][
j
];
for
(
j
=
0
;
j
<
16
;
j
++
)
huff
.
huffman_table
[
i
].
num_ac_codes
[
j
]
=
s
->
raw_huffman_lengths
[
1
][
i
][
j
];
for
(
j
=
0
;
j
<
162
;
j
++
)
huff
.
huffman_table
[
i
].
ac_values
[
j
]
=
s
->
raw_huffman_values
[
1
][
i
][
j
];
}
err
=
ff_vaapi_decode_make_param_buffer
(
avctx
,
pic
,
VAHuffmanTableBufferType
,
&
huff
,
sizeof
(
huff
));
if
(
err
<
0
)
goto
fail
;
memset
(
&
quant
,
0
,
sizeof
(
quant
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
quant
.
load_quantiser_table
[
i
]
=
1
;
for
(
j
=
0
;
j
<
64
;
j
++
)
quant
.
quantiser_table
[
i
][
j
]
=
s
->
quant_matrixes
[
i
][
j
];
}
err
=
ff_vaapi_decode_make_param_buffer
(
avctx
,
pic
,
VAIQMatrixBufferType
,
&
quant
,
sizeof
(
quant
));
if
(
err
<
0
)
goto
fail
;
sp
=
(
VASliceParameterBufferJPEGBaseline
)
{
.
slice_data_size
=
size
,
.
slice_data_offset
=
0
,
.
slice_data_flag
=
VA_SLICE_DATA_FLAG_ALL
,
.
slice_horizontal_position
=
0
,
.
slice_vertical_position
=
0
,
.
restart_interval
=
s
->
restart_interval
,
.
num_mcus
=
s
->
mb_width
*
s
->
mb_height
,
};
sp
.
num_components
=
s
->
nb_components
;
for
(
i
=
0
;
i
<
s
->
nb_components
;
i
++
)
{
sp
.
components
[
i
].
component_selector
=
s
->
component_id
[
s
->
comp_index
[
i
]];
sp
.
components
[
i
].
dc_table_selector
=
s
->
dc_index
[
i
];
sp
.
components
[
i
].
ac_table_selector
=
s
->
ac_index
[
i
];
}
err
=
ff_vaapi_decode_make_slice_buffer
(
avctx
,
pic
,
&
sp
,
sizeof
(
sp
),
buffer
,
size
);
if
(
err
)
goto
fail
;
return
0
;
fail:
ff_vaapi_decode_cancel
(
avctx
,
pic
);
return
err
;
}
const
AVHWAccel
ff_mjpeg_vaapi_hwaccel
=
{
.
name
=
"mjpeg_vaapi"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
id
=
AV_CODEC_ID_MJPEG
,
.
pix_fmt
=
AV_PIX_FMT_VAAPI
,
.
start_frame
=
&
vaapi_mjpeg_start_frame
,
.
end_frame
=
&
vaapi_mjpeg_end_frame
,
.
decode_slice
=
&
vaapi_mjpeg_decode_slice
,
.
frame_priv_data_size
=
sizeof
(
VAAPIDecodePicture
),
.
init
=
&
ff_vaapi_decode_init
,
.
uninit
=
&
ff_vaapi_decode_uninit
,
.
frame_params
=
&
ff_vaapi_common_frame_params
,
.
priv_data_size
=
sizeof
(
VAAPIDecodeContext
),
.
caps_internal
=
HWACCEL_CAP_ASYNC_SAFE
,
};
libavcodec/version.h
View file @
63c690ad
...
...
@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 12
#define LIBAVCODEC_VERSION_MICRO 10
0
#define LIBAVCODEC_VERSION_MICRO 10
1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment