Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: FFmpeg/FFmpeg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4abc411b97d7
Choose a base ref
...
head repository: FFmpeg/FFmpeg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c785b6db73f6
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 2, 2012

  1. ffmpeg: print muxed packet sizes in debug output too

    Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
    michaelni committed Oct 2, 2012
    Copy the full SHA
    44ae7ba View commit details
  2. Libspeex VAD support

    Option for Voice Activity Detection is added to speex encoder.
    
    Speex detects non-speech periods and encodes them with just enough bits
    to reproduce the background noise, aka ``comfort noise generation''.
    
    Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
    Dmitry Samonenko authored and michaelni committed Oct 2, 2012
    Copy the full SHA
    c785b6d View commit details
Showing with 12 additions and 2 deletions.
  1. +3 −2 ffmpeg.c
  2. +9 −0 libavcodec/libspeexenc.c
5 changes: 3 additions & 2 deletions ffmpeg.c
Original file line number Diff line number Diff line change
@@ -575,10 +575,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)

if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
av_get_media_type_string(ost->st->codec->codec_type),
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base)
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base),
pkt->size
);
}

9 changes: 9 additions & 0 deletions libavcodec/libspeexenc.c
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@
#include "internal.h"
#include "audio_frame_queue.h"

/* TODO: Think about converting abr, vad, dtx (still to come) and such flags to a bit field */
typedef struct {
AVClass *class; ///< AVClass for private options
SpeexBits bits; ///< libspeex bitwriter context
@@ -84,6 +85,7 @@ typedef struct {
float vbr_quality; ///< VBR quality 0.0 to 10.0
int cbr_quality; ///< CBR quality 0 to 10
int abr; ///< flag to enable ABR
int vad; ///< flag to enable VAD
int pkt_frame_count; ///< frame count for the current packet
AudioFrameQueue afq; ///< frame queue
} LibSpeexEncContext;
@@ -118,6 +120,7 @@ static av_cold void print_enc_params(AVCodecContext *avctx,
s->frames_per_packet);
av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n",
avctx->frame_size * s->frames_per_packet);
av_log(avctx, AV_LOG_DEBUG, "voice activity detection: %d\n", s->vad);
}

static av_cold int encode_init(AVCodecContext *avctx)
@@ -158,6 +161,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (avctx->flags & CODEC_FLAG_QSCALE) {
/* VBR */
s->header.vbr = 1;
s->vad = 1; /* VAD is always implicitly activated for VBR */
speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR, &s->header.vbr);
s->vbr_quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA,
0.0f, 10.0f);
@@ -189,6 +193,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->bit_rate = s->header.bitrate + (avctx->channels == 2 ? 800 : 0);
}

/* VAD is activated with VBR or can be turned on by itself */
if (s->vad)
speex_encoder_ctl(s->enc_state, SPEEX_SET_VAD, &s->vad);

/* set encoding complexity */
if (avctx->compression_level > FF_COMPRESSION_DEFAULT) {
complexity = av_clip(avctx->compression_level, 0, 10);
@@ -308,6 +316,7 @@ static const AVOption options[] = {
{ "abr", "Use average bit rate", OFFSET(abr), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE },
{ "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { .i64 = 8 }, 0, 10, AE },
{ "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 8, AE },
{ "vad", "Voice Activity Detection", OFFSET(vad), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE },
{ NULL },
};