mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 07:40:24 +00:00
Libavcodec: added VP8
This commit is contained in:
@@ -66,7 +66,8 @@ typedef enum {
|
||||
JPEG,
|
||||
RAW,
|
||||
H264,
|
||||
MJPG
|
||||
MJPG,
|
||||
VP8
|
||||
} codec_t;
|
||||
|
||||
enum interlacing_t {
|
||||
|
||||
@@ -81,6 +81,7 @@ const struct codec_info_t codec_info[] = {
|
||||
{RAW, "raw", to_fourcc('r','a','w','s'), 0, 1.0, FALSE, TRUE}, /* raw SDI */
|
||||
{H264, "H.264", to_fourcc('A','V','C','1'), 0, 1.0, FALSE, TRUE},
|
||||
{MJPG, "MJPEG", to_fourcc('M','J','P','G'), 0, 1.0, FALSE, TRUE},
|
||||
{VP8, "VP8", to_fourcc('V','P','8','0'), 0, 1.0, FALSE, TRUE},
|
||||
{(codec_t) 0, NULL, 0, 0, 0.0, FALSE, FALSE}
|
||||
};
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ static void usage() {
|
||||
printf("Libavcodec encoder usage:\n");
|
||||
printf("\t-c libavcodec[:codec=<codec_name>][:bitrate=<bits_per_sec>]\n");
|
||||
printf("\t\t<codec_name> may be "
|
||||
" one of \"H.264\" or "
|
||||
" one of \"H.264\", \"VP8\" or "
|
||||
"\"MJPEG\" (default)\n");
|
||||
printf("\t\t<bits_per_sec> specifies requested bitrate\n");
|
||||
printf("\t\t\t0 means codec default (same as when parameter omitted)\n");
|
||||
@@ -223,6 +223,16 @@ static bool configure_with(struct libav_video_compress *s, struct video_frame *f
|
||||
compressed_desc.color_spec = MJPG;
|
||||
avg_bpp = 0.7;
|
||||
break;
|
||||
case VP8:
|
||||
codec_id = CODEC_ID_VP8;
|
||||
#ifdef HAVE_AVCODEC_ENCODE_VIDEO2
|
||||
pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
#else
|
||||
pix_fmt = PIX_FMT_YUV420P;
|
||||
#endif
|
||||
compressed_desc.color_spec = VP8;
|
||||
avg_bpp = 0.5;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "[lavc] Requested output codec isn't "
|
||||
"supported by libavcodec.\n");
|
||||
@@ -295,6 +305,12 @@ static bool configure_with(struct libav_video_compress *s, struct video_frame *f
|
||||
av_opt_set(s->codec_ctx->priv_data, "preset", "ultrafast", 0);
|
||||
//av_opt_set(s->codec_ctx->priv_data, "tune", "fastdecode", 0);
|
||||
av_opt_set(s->codec_ctx->priv_data, "tune", "zerolatency", 0);
|
||||
} else if(codec_id == CODEC_ID_VP8) {
|
||||
s->codec_ctx->thread_count = 8;
|
||||
s->codec_ctx->profile = 3;
|
||||
s->codec_ctx->slices = 4;
|
||||
s->codec_ctx->rc_buffer_size = s->codec_ctx->bit_rate / frame->fps;
|
||||
s->codec_ctx->rc_buffer_aggressivity = 0.5;
|
||||
} else {
|
||||
// zero should mean count equal to the number of virtual cores
|
||||
if(s->codec->capabilities & CODEC_CAP_SLICE_THREADS) {
|
||||
|
||||
@@ -133,6 +133,7 @@ struct decode_from_to decoders_for_codec[] = {
|
||||
{ H264, UYVY, LIBAVCODEC_MAGIC, 500 },
|
||||
{ JPEG, UYVY, LIBAVCODEC_MAGIC, 600 },
|
||||
{ MJPG, UYVY, LIBAVCODEC_MAGIC, 500 },
|
||||
{ VP8, UYVY, LIBAVCODEC_MAGIC, 500 },
|
||||
{ (codec_t) -1, (codec_t) -1, NULL_MAGIC, 0 }
|
||||
};
|
||||
const int decoders_for_codec_count = (sizeof(decoders_for_codec) / sizeof(struct decode_from_to));
|
||||
|
||||
@@ -102,6 +102,9 @@ static bool configure_with(struct state_libavcodec_decompress *s,
|
||||
fprintf(stderr, "[lavd] Warning: JPEG decoder "
|
||||
"will use full-scale YUV.\n");
|
||||
break;
|
||||
case VP8:
|
||||
codec_id = CODEC_ID_VP8;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "[lavd] Unsupported codec!!!\n");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user