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: 047dcfabc7e8
Choose a base ref
...
head repository: FFmpeg/FFmpeg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 489d8a79a649
Choose a head ref

Commits on Oct 3, 2012

  1. blowfish: Factorize testing into a separate function

    Signed-off-by: Martin Storsjö <martin@martin.st>
    mstorsjo committed Oct 3, 2012
    Copy the full SHA
    0cc9a64 View commit details
  2. blowfish: Fix CBC decryption with dst==src

    Signed-off-by: Martin Storsjö <martin@martin.st>
    mstorsjo committed Oct 3, 2012
    Copy the full SHA
    87f023f View commit details
  3. blowfish: Add more tests

    Test inplace ECB, normal CBC and inplace CBC encryption/decryption.
    
    Signed-off-by: Martin Storsjö <martin@martin.st>
    mstorsjo committed Oct 3, 2012
    Copy the full SHA
    75366a5 View commit details
  4. Allow use of strncpy()

    There are cases where strncpy() does exactly what is required.
    A blanket ban forces more convoluted solutions to be used in those
    cases and has been a cause of bugs.
    
    Signed-off-by: Mans Rullgard <mans@mansr.com>
    mansr committed Oct 3, 2012
    Copy the full SHA
    05e209c View commit details
  5. Copy the full SHA
    8be5b0d View commit details
  6. Copy the full SHA
    fd712a5 View commit details
  7. xtea: Factorize testing into a separate function

    Based on a patch by Michael Niedermayer.
    
    Signed-off-by: Martin Storsjö <martin@martin.st>
    mstorsjo committed Oct 3, 2012
    Copy the full SHA
    ca074cc View commit details
  8. xtea: Fix CBC decryption when src==dst

    Signed-off-by: Martin Storsjö <martin@martin.st>
    michaelni authored and mstorsjo committed Oct 3, 2012
    Copy the full SHA
    b434500 View commit details
  9. xtea: Test inplace decryption

    Based on test code by: Giorgio Vazzana <mywing81@gmail.com>
    
    Signed-off-by: Martin Storsjö <martin@martin.st>
    michaelni authored and mstorsjo committed Oct 3, 2012
    Copy the full SHA
    f0fce9f View commit details
  10. libspeex: Add a private option for enabling VAD

    Speex detects non-speech periods and encodes them with just enough bits
    to reproduce the background noise, aka ``comfort noise generation''.
    
    Signed-off-by: Martin Storsjö <martin@martin.st>
    Dmitry Samonenko authored and mstorsjo committed Oct 3, 2012
    Copy the full SHA
    ad11681 View commit details
  11. libspeexdec: improve setting of Speex mode and sample rate

    If there is no extradata and the sample rate given by the user is not valid,
    decode as ultra-wideband.
    justinruggles committed Oct 3, 2012
    Copy the full SHA
    3b061c5 View commit details
  12. Copy the full SHA
    27c3f9c View commit details
  13. Copy the full SHA
    892695c View commit details
  14. Copy the full SHA
    908e22b View commit details
  15. Copy the full SHA
    45e5d0c View commit details
  16. libspeexdec: If the channel count is not valid, decode as stereo.

    When initialized as stereo, libspeex can decode either mono or stereo packets
    and will output stereo.
    justinruggles committed Oct 3, 2012
    Copy the full SHA
    29abb04 View commit details
  17. mpegvideo: set extended_data in ff_update_duplicate_context()

    AVFrame.extended_data has to reset to the AVFrame.data of the current
    thread context after copying the frame contents.
    Fixes crashes with frame-threading after 2bc0de3.
    Janne Grunau committed Oct 3, 2012
    Copy the full SHA
    1481e19 View commit details
  18. h264probe: Don't error out on bits that no longer are reserved

    Signed-off-by: Martin Storsjö <martin@martin.st>
    michaelni authored and mstorsjo committed Oct 3, 2012
    Copy the full SHA
    769ed30 View commit details
  19. libspeexdec: handle NULL return value from speex_packet_to_header()

    This will happen when the extradata is not a valid Speex header.
    justinruggles committed Oct 3, 2012
    Copy the full SHA
    c9df489 View commit details

Commits on Oct 4, 2012

  1. samplefmt: make av_samples_alloc() initialize the data to silence.

    Right now the buffer is zeroed, which does not represent silence for U8(P).
    elenril committed Oct 4, 2012
    Copy the full SHA
    cd15b7c View commit details
  2. vf_overlay: get rid of pointless messing with timebase.

    Output frames correspond 1:1 to input frames on the main input.
    So use the main input timebase for output.
    elenril committed Oct 4, 2012
    Copy the full SHA
    ab35ec2 View commit details
  3. vf_overlay: properly sync inputs.

    Right now it incorrectly assumes that the frames are sent in the proper
    order, which worked with old ffmpeg and avconv versions by accident.
    elenril committed Oct 4, 2012
    Copy the full SHA
    4673a5a View commit details
  4. Merge commit '29abb04e73b0580ebe38703cadb988d26df6a76a'

    * commit '29abb04e73b0580ebe38703cadb988d26df6a76a':
      libspeexdec: If the channel count is not valid, decode as stereo.
      libspeexdec: improve setting of Speex mode and sample rate
      libspeex: Add a private option for enabling VAD
      xtea: Test inplace decryption
      xtea: Fix CBC decryption when src==dst
      xtea: Factorize testing into a separate function
      configure: Refactor HAVE_ options available on the command line
      avconv/avprobe: Add missing 'void' to exit_program() definition
      Allow use of strncpy()
      blowfish: Add more tests
      blowfish: Fix CBC decryption with dst==src
      blowfish: Factorize testing into a separate function
    
    Conflicts:
    	configure
    	libavcodec/libspeexdec.c
    	libavutil/xtea.c
    
    Merged-by: Michael Niedermayer <michaelni@gmx.at>
    michaelni committed Oct 4, 2012
    Copy the full SHA
    741f5b0 View commit details
  5. Merge commit 'ab35ec29a4071871934856c00da7d6ebcc0c095b'

    * commit 'ab35ec29a4071871934856c00da7d6ebcc0c095b':
      vf_overlay: get rid of pointless messing with timebase.
      samplefmt: make av_samples_alloc() initialize the data to silence.
      libspeexdec: handle NULL return value from speex_packet_to_header()
      h264probe: Don't error out on bits that no longer are reserved
      mpegvideo: set extended_data in ff_update_duplicate_context()
      libspeexdec: properly handle DTX for multiple frames-per-packet
      libspeexdec: move the SpeexHeader from LibSpeexContext to where it is used
      libspeexdec: simplify setting of frame_size
      libspeexdec: set channel_layout
    
    Conflicts:
    	libavfilter/vf_overlay.c
    	libavformat/h264dec.c
    	libavutil/version.h
    
    Merged-by: Michael Niedermayer <michaelni@gmx.at>
    michaelni committed Oct 4, 2012
    Copy the full SHA
    0f1446a View commit details
  6. Merge remote-tracking branch 'qatar/master'

    * qatar/master:
      vf_overlay: properly sync inputs.
    
    Conflicts:
    	libavfilter/vf_overlay.c
    
    Merged-by: Michael Niedermayer <michaelni@gmx.at>
    michaelni committed Oct 4, 2012
    Copy the full SHA
    489d8a7 View commit details
Showing with 146 additions and 100 deletions.
  1. +8 −6 configure
  2. +48 −36 libavcodec/libspeexdec.c
  3. +5 −0 libavcodec/mpegvideo.c
  4. +5 −21 libavfilter/vf_overlay.c
  5. +1 −1 libavformat/h264dec.c
  6. +46 −17 libavutil/blowfish.c
  7. +0 −2 libavutil/internal.h
  8. +4 −1 libavutil/samplefmt.c
  9. +1 −0 libavutil/samplefmt.h
  10. +1 −1 libavutil/version.h
  11. +27 −15 libavutil/xtea.c
14 changes: 8 additions & 6 deletions configure
Original file line number Diff line number Diff line change
@@ -1243,6 +1243,12 @@ ARCH_EXT_LIST="
mipsdspr2
"

HAVE_LIST_CMDLINE='
inline_asm
symver
yasm
'

HAVE_LIST_PUB='
bigendian
fast_unaligned
@@ -1253,6 +1259,7 @@ HAVE_LIST="
$ARCH_EXT_LIST
$(add_suffix _external $ARCH_EXT_LIST)
$(add_suffix _inline $ARCH_EXT_LIST)
$HAVE_LIST_CMDLINE
$HAVE_LIST_PUB
$THREADS_LIST
aligned_malloc
@@ -1305,7 +1312,6 @@ HAVE_LIST="
gnu_as
ibm_asm
inet_aton
inline_asm
io_h
isatty
isinf
@@ -1369,7 +1375,6 @@ HAVE_LIST="
struct_sockaddr_sa_len
struct_sockaddr_storage
struct_v4l2_frmivalenum_discrete
symver
symver_asm_label
symver_gnu_asm
sysconf
@@ -1395,7 +1400,6 @@ HAVE_LIST="
xform_asm
xgetbv
xmm_clobbers
yasm
"

# options emitted with CONFIG_ prefix but not available on command line
@@ -1427,18 +1431,16 @@ CONFIG_EXTRA="
CMDLINE_SELECT="
$ARCH_EXT_LIST
$CONFIG_LIST
$HAVE_LIST_CMDLINE
$THREADS_LIST
asm
coverage
cross_compile
debug
extra_warnings
inline_asm
logging
optimizations
stripping
symver
yasm
"

PATHS_LIST='
84 changes: 48 additions & 36 deletions libavcodec/libspeexdec.c
Original file line number Diff line number Diff line change
@@ -22,15 +22,16 @@
#include <speex/speex_header.h>
#include <speex/speex_stereo.h>
#include <speex/speex_callbacks.h>
#include "avcodec.h"

#include "libavutil/audioconvert.h"
#include "libavutil/common.h"
#include "avcodec.h"

typedef struct {
AVFrame frame;
SpeexBits bits;
SpeexStereoState stereo;
void *dec_state;
SpeexHeader *header;
int frame_size;
} LibSpeexContext;

@@ -39,36 +40,50 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;
const SpeexMode *mode;

// defaults in the case of a missing header
if (avctx->sample_rate <= 8000)
mode = &speex_nb_mode;
else if (avctx->sample_rate <= 16000)
mode = &speex_wb_mode;
else
mode = &speex_uwb_mode;

if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
SpeexHeader *header = NULL;
int spx_mode;

avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
s->frame_size = s->header->frame_size;

mode = speex_lib_get_mode(s->header->mode);
if (!mode) {
av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d\n", s->header->mode);
return AVERROR_INVALIDDATA;
if (avctx->extradata && avctx->extradata_size >= 80) {
header = speex_packet_to_header(avctx->extradata,
avctx->extradata_size);
if (!header)
av_log(avctx, AV_LOG_WARNING, "Invalid Speex header\n");
}
if (header) {
avctx->channels = header->nb_channels;
spx_mode = header->mode;
speex_header_free(header);
} else {
switch (avctx->sample_rate) {
case 8000: spx_mode = 0; break;
case 16000: spx_mode = 1; break;
case 32000: spx_mode = 2; break;
default:
/* libspeex can handle any mode if initialized as ultra-wideband */
av_log(avctx, AV_LOG_WARNING, "Invalid sample rate: %d\n"
"Decoding as 32kHz ultra-wideband\n",
avctx->sample_rate);
spx_mode = 2;
}
} else
av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n");
}

if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
return AVERROR(EINVAL);
mode = speex_lib_get_mode(spx_mode);
if (!mode) {
av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", spx_mode);
return AVERROR_INVALIDDATA;
}
avctx->sample_rate = 8000 << spx_mode;
s->frame_size = 160 << spx_mode;

if (avctx->channels < 1 || avctx->channels > 2) {
/* libspeex can handle mono or stereo if initialized as stereo */
av_log(avctx, AV_LOG_ERROR, "Invalid channel count: %d.\n"
"Decoding as stereo.\n", avctx->channels);
avctx->channels = 2;
}
avctx->channel_layout = avctx->channels == 2 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;

speex_bits_init(&s->bits);
s->dec_state = speex_decoder_init(mode);
@@ -77,10 +92,6 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
return -1;
}

if (!s->header) {
speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
}

if (avctx->channels == 2) {
SpeexCallback callback;
callback.callback_id = SPEEX_INBAND_STEREO;
@@ -113,10 +124,12 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
}
output = (int16_t *)s->frame.data[0];

/* if there is not enough data left for the smallest possible frame,
reset the libspeex buffer using the current packet, otherwise ignore
the current packet and keep decoding frames from the libspeex buffer. */
if (speex_bits_remaining(&s->bits) < 43) {
/* if there is not enough data left for the smallest possible frame or the
next 5 bits are a terminator code, reset the libspeex buffer using the
current packet, otherwise ignore the current packet and keep decoding
frames from the libspeex buffer. */
if (speex_bits_remaining(&s->bits) < 5 ||
speex_bits_peek_unsigned(&s->bits, 5) == 0x1F) {
/* check for flush packet */
if (!buf || !buf_size) {
*got_frame_ptr = 0;
@@ -146,7 +159,6 @@ static av_cold int libspeex_decode_close(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;

speex_header_free(s->header);
speex_bits_destroy(&s->bits);
speex_decoder_destroy(s->dec_state);

5 changes: 5 additions & 0 deletions libavcodec/mpegvideo.c
Original file line number Diff line number Diff line change
@@ -531,6 +531,7 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
int ff_mpeg_update_thread_context(AVCodecContext *dst,
const AVCodecContext *src)
{
int i;
MpegEncContext *s = dst->priv_data, *s1 = src->priv_data;

if (dst == src)
@@ -574,6 +575,10 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
memcpy(&s->last_picture, &s1->last_picture,
(char *) &s1->last_picture_ptr - (char *) &s1->last_picture);

// reset s->picture[].f.extended_data to s->picture[].f.data
for (i = 0; i < s->picture_count; i++)
s->picture[i].f.extended_data = s->picture[i].f.data;

s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1);
s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1);
s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1);
26 changes: 5 additions & 21 deletions libavfilter/vf_overlay.c
Original file line number Diff line number Diff line change
@@ -276,24 +276,10 @@ static int config_input_overlay(AVFilterLink *inlink)
static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
int exact;
// common timebase computation:
AVRational tb1 = ctx->inputs[MAIN ]->time_base;
AVRational tb2 = ctx->inputs[OVERLAY]->time_base;
AVRational *tb = &ctx->outputs[0]->time_base;
exact = av_reduce(&tb->num, &tb->den,
av_gcd((int64_t)tb1.num * tb2.den,
(int64_t)tb2.num * tb1.den),
(int64_t)tb1.den * tb2.den, INT_MAX);
av_log(ctx, AV_LOG_VERBOSE,
"main_tb:%d/%d overlay_tb:%d/%d -> tb:%d/%d exact:%d\n",
tb1.num, tb1.den, tb2.num, tb2.den, tb->num, tb->den, exact);
if (!exact)
av_log(ctx, AV_LOG_WARNING,
"Timestamp conversion inexact, timestamp information loss may occurr\n");

outlink->w = ctx->inputs[MAIN]->w;
outlink->h = ctx->inputs[MAIN]->h;
outlink->time_base = ctx->inputs[MAIN]->time_base;

return 0;
}
@@ -448,7 +434,8 @@ static int try_start_frame(AVFilterContext *ctx, AVFilterBufferRef *mainpic)
* before the main frame, we can drop the current overlay. */
while (1) {
next_overpic = ff_bufqueue_peek(&over->queue_over, 0);
if (!next_overpic || next_overpic->pts > mainpic->pts)
if (!next_overpic || av_compare_ts(next_overpic->pts, ctx->inputs[OVERLAY]->time_base,
mainpic->pts , ctx->inputs[MAIN]->time_base) > 0)
break;
ff_bufqueue_get(&over->queue_over);
avfilter_unref_buffer(over->overpicref);
@@ -457,7 +444,8 @@ static int try_start_frame(AVFilterContext *ctx, AVFilterBufferRef *mainpic)
/* If there is no next frame and no EOF and the overlay frame is before
* the main frame, we can not know yet if it will be superseded. */
if (!over->queue_over.available && !over->overlay_eof &&
(!over->overpicref || over->overpicref->pts < mainpic->pts))
(!over->overpicref || av_compare_ts(over->overpicref->pts, ctx->inputs[OVERLAY]->time_base,
mainpic->pts , ctx->inputs[MAIN]->time_base) < 0))
return AVERROR(EAGAIN);
/* At this point, we know that the current overlay frame extends to the
* time of the main frame. */
@@ -525,8 +513,6 @@ static int start_frame_main(AVFilterLink *inlink, AVFilterBufferRef *inpicref)

if ((ret = flush_frames(ctx)) < 0)
return ret;
inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[MAIN]->time_base,
ctx->outputs[0]->time_base);
if ((ret = try_start_frame(ctx, inpicref)) < 0) {
if (ret != AVERROR(EAGAIN))
return ret;
@@ -583,8 +569,6 @@ static int end_frame_over(AVFilterLink *inlink)

if ((ret = flush_frames(ctx)) < 0)
return ret;
inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base,
ctx->outputs[0]->time_base);
ff_bufqueue_add(ctx, &over->queue_over, inpicref);
ret = try_push_frame(ctx);
return ret == AVERROR(EAGAIN) ? 0 : ret;
2 changes: 1 addition & 1 deletion libavformat/h264dec.c
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ static int h264_probe(AVProbeData *p)
case 1: sli++; break;
case 5: idr++; break;
case 7:
if(p->buf[i+2]&0x03)
if (p->buf[i + 2] & 0x03)
return 0;
sps++;
break;
63 changes: 46 additions & 17 deletions libavutil/blowfish.c
Original file line number Diff line number Diff line change
@@ -380,15 +380,15 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,

av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);

AV_WB32(dst, v0);
AV_WB32(dst + 4, v1);

if (iv) {
for (i = 0; i < 8; i++)
dst[i] = dst[i] ^ iv[i];
v0 ^= AV_RB32(iv);
v1 ^= AV_RB32(iv + 4);
memcpy(iv, src, 8);
}

AV_WB32(dst, v0);
AV_WB32(dst + 4, v1);

src += 8;
dst += 8;
}
@@ -509,32 +509,61 @@ static const uint32_t ciphertext_r[NUM_VARIABLE_KEY_TESTS] = {
/* plaintext bytes */
static const uint8_t plaintext[8] = "BLOWFISH";

static const uint8_t plaintext2[16] = "BLOWFISHBLOWFISH";

/* ciphertext bytes */
static const uint8_t ciphertext[8] = {
0x32, 0x4E, 0xD0, 0xFE, 0xF4, 0x13, 0xA2, 0x03
};

static const uint8_t ciphertext2[16] = {
0x53, 0x00, 0x40, 0x06, 0x63, 0xf2, 0x1d, 0x99,
0x3b, 0x9b, 0x27, 0x64, 0x46, 0xfd, 0x20, 0xc1,
};

#define IV "blowfish"

#undef exit
static void test_blowfish(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
const uint8_t *ref, int len, uint8_t *iv, int dir,
const char *test)
{
av_blowfish_crypt(ctx, dst, src, len, iv, dir);
if (memcmp(dst, ref, 8*len)) {
int i;
printf("%s failed\ngot ", test);
for (i = 0; i < 8*len; i++)
printf("%02x ", dst[i]);
printf("\nexpected ");
for (i = 0; i < 8*len; i++)
printf("%02x ", ref[i]);
printf("\n");
exit(1);
}
}

int main(void)
{
AVBlowfish ctx;
uint32_t tmptext_l[NUM_VARIABLE_KEY_TESTS];
uint32_t tmptext_r[NUM_VARIABLE_KEY_TESTS];
uint8_t tmp[8];
uint8_t tmp[16], iv[8];
int i;

av_blowfish_init(&ctx, "abcdefghijklmnopqrstuvwxyz", 26);

av_blowfish_crypt(&ctx, tmp, plaintext, 1, NULL, 0);
if (memcmp(tmp, ciphertext, 8)) {
printf("Test encryption failed.\n");
return 1;
}

av_blowfish_crypt(&ctx, tmp, ciphertext, 1, NULL, 1);
if (memcmp(tmp, plaintext, 8)) {
printf("Test decryption failed.\n");
return 1;
}
test_blowfish(&ctx, tmp, plaintext, ciphertext, 1, NULL, 0, "encryption");
test_blowfish(&ctx, tmp, ciphertext, plaintext, 1, NULL, 1, "decryption");
test_blowfish(&ctx, tmp, tmp, ciphertext, 1, NULL, 0, "Inplace encryption");
test_blowfish(&ctx, tmp, tmp, plaintext, 1, NULL, 1, "Inplace decryption");
memcpy(iv, IV, 8);
test_blowfish(&ctx, tmp, plaintext2, ciphertext2, 2, iv, 0, "CBC encryption");
memcpy(iv, IV, 8);
test_blowfish(&ctx, tmp, ciphertext2, plaintext2, 2, iv, 1, "CBC decryption");
memcpy(iv, IV, 8);
test_blowfish(&ctx, tmp, tmp, ciphertext2, 2, iv, 0, "Inplace CBC encryption");
memcpy(iv, IV, 8);
test_blowfish(&ctx, tmp, tmp, plaintext2, 2, iv, 1, "Inplace CBC decryption");

memcpy(tmptext_l, plaintext_l, sizeof(*plaintext_l) * NUM_VARIABLE_KEY_TESTS);
memcpy(tmptext_r, plaintext_r, sizeof(*plaintext_r) * NUM_VARIABLE_KEY_TESTS);
2 changes: 0 additions & 2 deletions libavutil/internal.h
Original file line number Diff line number Diff line change
@@ -71,8 +71,6 @@
#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
#undef strcat
#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
#undef strncpy
#define strncpy strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy
#undef exit
#define exit exit_is_forbidden
#undef printf
Loading