提交 00179664 编写于 作者: M Mark Thompson

vaapi_h265: Convert to use coded bitstream infrastructure

Also improves the metadata and generally makes the configuration
a bit cleaner.

(cherry picked from commit ac124867)
上级 94a40486
......@@ -2845,7 +2845,7 @@ hevc_qsv_encoder_select="hevcparse qsvenc"
hevc_rkmpp_decoder_deps="rkmpp"
hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
hevc_vaapi_encoder_select="vaapi_encode golomb"
hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
mjpeg_cuvid_decoder_deps="cuda cuvid"
......
......@@ -363,7 +363,7 @@ OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o \
hevc_data.o
OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o vaapi_encode_h26x.o
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o
OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
......
此差异已折叠。
/*
* 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 <stdint.h>
#include "vaapi_encode_h26x.h"
int ff_vaapi_encode_h26x_nal_unit_to_byte_stream(uint8_t *dst, size_t *dst_bit_len,
uint8_t *src, size_t src_bit_len)
{
size_t dp, sp;
int zero_run = 0;
size_t dst_len = *dst_bit_len / 8;
size_t src_len = (src_bit_len + 7) / 8;
int trailing_zeroes = src_len * 8 - src_bit_len;
if (dst_len < src_len + 4) {
// Definitely doesn't fit.
goto fail;
}
// Start code.
dst[0] = dst[1] = dst[2] = 0;
dst[3] = 1;
dp = 4;
for (sp = 0; sp < src_len; sp++) {
if (dp >= dst_len)
goto fail;
if (zero_run < 2) {
if (src[sp] == 0)
++zero_run;
else
zero_run = 0;
} else {
if ((src[sp] & ~3) == 0) {
// emulation_prevention_three_byte
dst[dp++] = 3;
if (dp >= dst_len)
goto fail;
}
zero_run = src[sp] == 0;
}
dst[dp++] = src[sp];
}
*dst_bit_len = 8 * dp - trailing_zeroes;
return 0;
fail:
*dst_bit_len = 0;
return AVERROR(ENOSPC);
}
/*
* 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
*/
#ifndef AVCODEC_VAAPI_ENCODE_H26X_H
#define AVCODEC_VAAPI_ENCODE_H26X_H
#include <stddef.h>
#include <stdint.h>
#include "golomb.h"
#include "put_bits.h"
// Debug code may be interested in the name of the syntax element being
// for tracing purposes. Here, it is just discarded.
#define write_u(pbc, width, value, name) put_bits(pbc, width, value)
#define write_ue(pbc, value, name) set_ue_golomb(pbc, value)
#define write_se(pbc, value, name) set_se_golomb(pbc, value)
#define u(width, ...) write_u(pbc, width, __VA_ARGS__)
#define ue(...) write_ue(pbc, __VA_ARGS__)
#define se(...) write_se(pbc, __VA_ARGS__)
// Copy from src to dst, applying emulation prevention.
int ff_vaapi_encode_h26x_nal_unit_to_byte_stream(uint8_t *dst, size_t *dst_len,
uint8_t *src, size_t src_len);
#endif /* AVCODEC_VAAPI_ENCODE_H26X_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册