mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
swr: add swr_drop_output()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
7a59964ba9
commit
f88f705abc
@ -596,6 +596,27 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
|
|||||||
AudioData * in= &s->in;
|
AudioData * in= &s->in;
|
||||||
AudioData *out= &s->out;
|
AudioData *out= &s->out;
|
||||||
|
|
||||||
|
if(s->drop_output > 0){
|
||||||
|
int ret;
|
||||||
|
AudioData tmp = s->out;
|
||||||
|
uint8_t *tmp_arg[SWR_CH_MAX];
|
||||||
|
tmp.count = 0;
|
||||||
|
tmp.data = NULL;
|
||||||
|
if((ret=realloc_audio(&tmp, s->drop_output))<0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
reversefill_audiodata(&tmp, tmp_arg);
|
||||||
|
s->drop_output *= -1; //FIXME find a less hackish solution
|
||||||
|
ret = swr_convert(s, tmp_arg, -s->drop_output, in_arg, in_count); //FIXME optimize but this is as good as never called so maybe it doesnt matter
|
||||||
|
s->drop_output *= -1;
|
||||||
|
if(ret>0)
|
||||||
|
s->drop_output -= ret;
|
||||||
|
|
||||||
|
av_freep(&tmp.data);
|
||||||
|
if(s->drop_output || !out_arg)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!in_arg){
|
if(!in_arg){
|
||||||
if(s->in_buffer_count){
|
if(s->in_buffer_count){
|
||||||
if (s->resample && !s->flushed) {
|
if (s->resample && !s->flushed) {
|
||||||
@ -676,6 +697,16 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int swr_drop_output(struct SwrContext *s, int count){
|
||||||
|
s->drop_output += count;
|
||||||
|
|
||||||
|
if(s->drop_output <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
av_log(s, AV_LOG_VERBOSE, "discarding %d audio samples\n", count);
|
||||||
|
return swr_convert(s, NULL, s->drop_output, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int swr_inject_silence(struct SwrContext *s, int count){
|
int swr_inject_silence(struct SwrContext *s, int count){
|
||||||
int ret, i;
|
int ret, i;
|
||||||
AudioData silence = s->out;
|
AudioData silence = s->out;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "libavutil/samplefmt.h"
|
#include "libavutil/samplefmt.h"
|
||||||
|
|
||||||
#define LIBSWRESAMPLE_VERSION_MAJOR 0
|
#define LIBSWRESAMPLE_VERSION_MAJOR 0
|
||||||
#define LIBSWRESAMPLE_VERSION_MINOR 13
|
#define LIBSWRESAMPLE_VERSION_MINOR 14
|
||||||
#define LIBSWRESAMPLE_VERSION_MICRO 100
|
#define LIBSWRESAMPLE_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
|
#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
|
||||||
@ -158,6 +158,11 @@ int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map);
|
|||||||
*/
|
*/
|
||||||
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride);
|
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drops the specified number of output samples.
|
||||||
|
*/
|
||||||
|
int swr_drop_output(struct SwrContext *s, int count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects the specified number of silence samples.
|
* Injects the specified number of silence samples.
|
||||||
*/
|
*/
|
||||||
|
@ -77,6 +77,7 @@ struct SwrContext {
|
|||||||
int in_buffer_count; ///< cached buffer length
|
int in_buffer_count; ///< cached buffer length
|
||||||
int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise
|
int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise
|
||||||
int flushed; ///< 1 if data is to be flushed and no further input is expected
|
int flushed; ///< 1 if data is to be flushed and no further input is expected
|
||||||
|
int drop_output; ///< number of output samples to drop
|
||||||
|
|
||||||
struct AudioConvert *in_convert; ///< input conversion context
|
struct AudioConvert *in_convert; ///< input conversion context
|
||||||
struct AudioConvert *out_convert; ///< output conversion context
|
struct AudioConvert *out_convert; ///< output conversion context
|
||||||
|
Loading…
Reference in New Issue
Block a user