webm: add support for V_VP9
Tags VP9 tracks with the V_VP9 video type when writing to .webm files, and supports decoding both from vpxdec without specifying --codec. Change-Id: I0ef61dee06f4db2a74032b142a4b4976c51faf6e
This commit is contained in:
Родитель
a3384f00a3
Коммит
08b43fef3a
|
@ -67,6 +67,7 @@ extern "C" {
|
|||
|
||||
#define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */
|
||||
#define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis codec. */
|
||||
#define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
|
||||
|
||||
#define NESTEGG_SEEK_SET 0 /**< Seek offset relative to beginning of stream. */
|
||||
#define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */
|
||||
|
|
|
@ -127,6 +127,7 @@ enum ebml_type_enum {
|
|||
|
||||
/* Track IDs */
|
||||
#define TRACK_ID_VP8 "V_VP8"
|
||||
#define TRACK_ID_VP9 "V_VP9"
|
||||
#define TRACK_ID_VORBIS "A_VORBIS"
|
||||
|
||||
enum vint_mask {
|
||||
|
@ -1669,6 +1670,9 @@ nestegg_track_codec_id(nestegg * ctx, unsigned int track)
|
|||
if (strcmp(codec_id, TRACK_ID_VP8) == 0)
|
||||
return NESTEGG_CODEC_VP8;
|
||||
|
||||
if (strcmp(codec_id, TRACK_ID_VP9) == 0)
|
||||
return NESTEGG_CODEC_VP9;
|
||||
|
||||
if (strcmp(codec_id, TRACK_ID_VORBIS) == 0)
|
||||
return NESTEGG_CODEC_VORBIS;
|
||||
|
||||
|
|
11
vpxdec.c
11
vpxdec.c
|
@ -537,6 +537,7 @@ file_is_webm(struct input_ctx *input,
|
|||
unsigned int *fps_num) {
|
||||
unsigned int i, n;
|
||||
int track_type = -1;
|
||||
int codec_id;
|
||||
|
||||
nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb, 0};
|
||||
nestegg_video_params params;
|
||||
|
@ -557,8 +558,13 @@ file_is_webm(struct input_ctx *input,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (nestegg_track_codec_id(input->nestegg_ctx, i) != NESTEGG_CODEC_VP8) {
|
||||
fprintf(stderr, "Not VP8 video, quitting.\n");
|
||||
codec_id = nestegg_track_codec_id(input->nestegg_ctx, i);
|
||||
if (codec_id == NESTEGG_CODEC_VP8) {
|
||||
*fourcc = VP8_FOURCC;
|
||||
} else if (codec_id == NESTEGG_CODEC_VP9) {
|
||||
*fourcc = VP9_FOURCC;
|
||||
} else {
|
||||
fprintf(stderr, "Not VPx video, quitting.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -569,7 +575,6 @@ file_is_webm(struct input_ctx *input,
|
|||
|
||||
*fps_den = 0;
|
||||
*fps_num = 0;
|
||||
*fourcc = VP8_FOURCC;
|
||||
*width = params.width;
|
||||
*height = params.height;
|
||||
return 1;
|
||||
|
|
19
vpxenc.c
19
vpxenc.c
|
@ -86,6 +86,8 @@ static size_t wrap_fwrite(const void *ptr, size_t size, size_t nmemb,
|
|||
|
||||
static const char *exec_name;
|
||||
|
||||
#define VP8_FOURCC (0x00385056)
|
||||
#define VP9_FOURCC (0x00395056)
|
||||
static const struct codec_item {
|
||||
char const *name;
|
||||
const vpx_codec_iface_t *(*iface)(void);
|
||||
|
@ -93,14 +95,14 @@ static const struct codec_item {
|
|||
unsigned int fourcc;
|
||||
} codecs[] = {
|
||||
#if CONFIG_VP8_ENCODER && CONFIG_VP8_DECODER
|
||||
{"vp8", &vpx_codec_vp8_cx, &vpx_codec_vp8_dx, 0x30385056},
|
||||
{"vp8", &vpx_codec_vp8_cx, &vpx_codec_vp8_dx, VP8_FOURCC},
|
||||
#elif CONFIG_VP8_ENCODER && !CONFIG_VP8_DECODER
|
||||
{"vp8", &vpx_codec_vp8_cx, NULL, 0x30385056},
|
||||
{"vp8", &vpx_codec_vp8_cx, NULL, VP8_FOURCC},
|
||||
#endif
|
||||
#if CONFIG_VP9_ENCODER && CONFIG_VP9_DECODER
|
||||
{"vp9", &vpx_codec_vp9_cx, &vpx_codec_vp9_dx, 0x30395056},
|
||||
{"vp9", &vpx_codec_vp9_cx, &vpx_codec_vp9_dx, VP9_FOURCC},
|
||||
#elif CONFIG_VP9_ENCODER && !CONFIG_VP9_DECODER
|
||||
{"vp9", &vpx_codec_vp9_cx, NULL, 0x30395056},
|
||||
{"vp9", &vpx_codec_vp9_cx, NULL, VP9_FOURCC},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -663,7 +665,8 @@ static void
|
|||
write_webm_file_header(EbmlGlobal *glob,
|
||||
const vpx_codec_enc_cfg_t *cfg,
|
||||
const struct vpx_rational *fps,
|
||||
stereo_format_t stereo_fmt) {
|
||||
stereo_format_t stereo_fmt,
|
||||
unsigned int fourcc) {
|
||||
{
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, EBML);
|
||||
|
@ -696,7 +699,8 @@ write_webm_file_header(EbmlGlobal *glob,
|
|||
glob->track_id_pos = ftello(glob->stream);
|
||||
Ebml_SerializeUnsigned32(glob, TrackUID, trackID);
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 1);
|
||||
Ebml_SerializeString(glob, CodecID, "V_VP8");
|
||||
Ebml_SerializeString(glob, CodecID,
|
||||
fourcc == VP8_FOURCC ? "V_VP8" : "V_VP9");
|
||||
{
|
||||
unsigned int pixelWidth = cfg->g_w;
|
||||
unsigned int pixelHeight = cfg->g_h;
|
||||
|
@ -2028,7 +2032,8 @@ static void open_output_file(struct stream_state *stream,
|
|||
stream->ebml.stream = stream->file;
|
||||
write_webm_file_header(&stream->ebml, &stream->config.cfg,
|
||||
&global->framerate,
|
||||
stream->config.stereo_fmt);
|
||||
stream->config.stereo_fmt,
|
||||
global->codec->fourcc);
|
||||
} else
|
||||
write_ivf_file_header(stream->file, &stream->config.cfg,
|
||||
global->codec->fourcc, 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче