You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
ffv1enc_vulkan: support 8 and 16-bit 2-plane YUV formats
This adds support for all 8-bit and 16-bit 2-plane formats. P010 and others require more work as the data's LSB-padded.
This commit is contained in:
@ -839,6 +839,9 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
|
||||
s->bits_per_raw_sample = 14;
|
||||
s->packed_at_lsb = 1;
|
||||
case AV_PIX_FMT_GRAY16:
|
||||
case AV_PIX_FMT_P016:
|
||||
case AV_PIX_FMT_P216:
|
||||
case AV_PIX_FMT_P416:
|
||||
case AV_PIX_FMT_YUV444P16:
|
||||
case AV_PIX_FMT_YUV422P16:
|
||||
case AV_PIX_FMT_YUV420P16:
|
||||
@ -859,6 +862,9 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
|
||||
s->version = FFMAX(s->version, 1);
|
||||
case AV_PIX_FMT_GRAY8:
|
||||
case AV_PIX_FMT_YA8:
|
||||
case AV_PIX_FMT_NV12:
|
||||
case AV_PIX_FMT_NV16:
|
||||
case AV_PIX_FMT_NV24:
|
||||
case AV_PIX_FMT_YUV444P:
|
||||
case AV_PIX_FMT_YUV440P:
|
||||
case AV_PIX_FMT_YUV422P:
|
||||
|
@ -141,6 +141,7 @@ typedef struct FFv1VkParameters {
|
||||
uint8_t micro_version;
|
||||
uint8_t force_pcm;
|
||||
uint8_t key_frame;
|
||||
uint8_t components;
|
||||
uint8_t planes;
|
||||
uint8_t codec_planes;
|
||||
uint8_t transparency;
|
||||
@ -149,7 +150,7 @@ typedef struct FFv1VkParameters {
|
||||
uint8_t ec;
|
||||
uint8_t ppi;
|
||||
uint8_t chunks;
|
||||
uint8_t padding[2];
|
||||
uint8_t padding[1];
|
||||
} FFv1VkParameters;
|
||||
|
||||
static void add_push_data(FFVulkanShader *shd)
|
||||
@ -173,6 +174,7 @@ static void add_push_data(FFVulkanShader *shd)
|
||||
GLSLC(1, uint8_t micro_version; );
|
||||
GLSLC(1, uint8_t force_pcm; );
|
||||
GLSLC(1, uint8_t key_frame; );
|
||||
GLSLC(1, uint8_t components; );
|
||||
GLSLC(1, uint8_t planes; );
|
||||
GLSLC(1, uint8_t codec_planes; );
|
||||
GLSLC(1, uint8_t transparency; );
|
||||
@ -181,7 +183,7 @@ static void add_push_data(FFVulkanShader *shd)
|
||||
GLSLC(1, uint8_t ec; );
|
||||
GLSLC(1, uint8_t ppi; );
|
||||
GLSLC(1, uint8_t chunks; );
|
||||
GLSLC(1, uint8_t padding[2]; );
|
||||
GLSLC(1, uint8_t padding[1]; );
|
||||
GLSLC(0, }; );
|
||||
ff_vk_shader_add_push_const(shd, 0, sizeof(FFv1VkParameters),
|
||||
VK_SHADER_STAGE_COMPUTE_BIT);
|
||||
@ -326,6 +328,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx,
|
||||
|
||||
int has_inter = avctx->gop_size > 1;
|
||||
uint32_t context_count = f->context_count[f->context_model];
|
||||
const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
|
||||
|
||||
VkImageView in_views[AV_NUM_DATA_POINTERS];
|
||||
VkImageView intermediate_views[AV_NUM_DATA_POINTERS];
|
||||
@ -498,6 +501,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx,
|
||||
.micro_version = f->micro_version,
|
||||
.force_pcm = fv->force_pcm,
|
||||
.key_frame = f->key_frame,
|
||||
.components = fmt_desc->nb_components,
|
||||
.planes = av_pix_fmt_count_planes(avctx->sw_pix_fmt),
|
||||
.codec_planes = f->plane_count,
|
||||
.transparency = f->transparency,
|
||||
|
@ -26,14 +26,18 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
|
||||
|
||||
#ifndef GOLOMB
|
||||
if (sc.slice_coding_mode == 1) {
|
||||
for (int p = 0; p < planes; p++) {
|
||||
for (int c = 0; c < components; c++) {
|
||||
|
||||
int h = sc.slice_dim.y;
|
||||
if (p > 0 && p < 3)
|
||||
if (c > 0 && c < 3)
|
||||
h >>= chroma_shift.y;
|
||||
|
||||
/* Takes into account dual-plane YUV formats */
|
||||
int p = min(c, planes - 1);
|
||||
int comp = c - p;
|
||||
|
||||
for (int y = 0; y < h; y++)
|
||||
encode_line_pcm(sc, y, p, 0, bits);
|
||||
encode_line_pcm(sc, y, p, comp, bits);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@ -41,18 +45,21 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
|
||||
uint64_t slice_state_off = uint64_t(slice_state) +
|
||||
slice_idx*plane_state_size*codec_planes;
|
||||
|
||||
for (int p = 0; p < planes; p++) {
|
||||
for (int c = 0; c < components; c++) {
|
||||
int run_index = 0;
|
||||
|
||||
int h = sc.slice_dim.y;
|
||||
if (p > 0 && p < 3)
|
||||
if (c > 0 && c < 3)
|
||||
h >>= chroma_shift.y;
|
||||
|
||||
int p = min(c, planes - 1);
|
||||
int comp = c - p;
|
||||
|
||||
for (int y = 0; y < h; y++)
|
||||
encode_line(sc, slice_state_off, y, p, 0, bits, run_index);
|
||||
encode_line(sc, slice_state_off, y, p, comp, bits, run_index);
|
||||
|
||||
/* For the second chroma plane, reuse the first plane's state */
|
||||
if (p != 1)
|
||||
if (c != 1)
|
||||
slice_state_off += plane_state_size;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user