Merge pull request #1666 from signalwire/av_fill
[mod_av] Avoid using 16384 stack (or heap) bytes in av_file_write(). Remove ff_input_buffer_padding static variable.
This commit is contained in:
commit
c134b8b73b
|
@ -405,8 +405,6 @@ typedef struct h264_codec_context_s {
|
||||||
#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
|
#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t ff_input_buffer_padding[AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
|
|
||||||
|
|
||||||
#define MAX_PROFILES 100
|
#define MAX_PROFILES 100
|
||||||
|
|
||||||
typedef struct avcodec_profile_s {
|
typedef struct avcodec_profile_s {
|
||||||
|
@ -753,8 +751,7 @@ static switch_status_t buffer_h263_rfc4629_packets(h264_codec_context_t *context
|
||||||
if (len < 0) return SWITCH_STATUS_FALSE;
|
if (len < 0) return SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
if (startcode) {
|
if (startcode) {
|
||||||
uint8_t zeros[2] = { 0 };
|
switch_buffer_zero_fill(context->nalu_buffer, 2);
|
||||||
switch_buffer_write(context->nalu_buffer, zeros, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_buffer_write(context->nalu_buffer, data, len);
|
switch_buffer_write(context->nalu_buffer, data, len);
|
||||||
|
@ -1712,7 +1709,7 @@ static switch_status_t switch_h264_decode(switch_codec_t *codec, switch_frame_t
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
switch_buffer_write(context->nalu_buffer, ff_input_buffer_padding, sizeof(ff_input_buffer_padding));
|
switch_buffer_zero_fill(context->nalu_buffer, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
switch_buffer_peek_zerocopy(context->nalu_buffer, (const void **)&pkt.data);
|
switch_buffer_peek_zerocopy(context->nalu_buffer, (const void **)&pkt.data);
|
||||||
pkt.size = size;
|
pkt.size = size;
|
||||||
|
|
||||||
|
|
|
@ -2043,7 +2043,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
||||||
int lead_frames = (context->offset * fps) / 1000;
|
int lead_frames = (context->offset * fps) / 1000;
|
||||||
|
|
||||||
for (int x = 0; x < lead_frames; x++) {
|
for (int x = 0; x < lead_frames; x++) {
|
||||||
switch_buffer_write(context->audio_buffer, buf, datalen);
|
switch_buffer_zero_fill(context->audio_buffer, datalen);
|
||||||
}
|
}
|
||||||
context->offset = 0;
|
context->offset = 0;
|
||||||
}
|
}
|
||||||
|
@ -2063,8 +2063,7 @@ GCC_DIAG_ON(deprecated-declarations)
|
||||||
if (context->closed) {
|
if (context->closed) {
|
||||||
inuse = switch_buffer_inuse(context->audio_buffer);
|
inuse = switch_buffer_inuse(context->audio_buffer);
|
||||||
if (inuse < bytes) {
|
if (inuse < bytes) {
|
||||||
char buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
|
switch_buffer_zero_fill(context->audio_buffer, bytes - inuse);
|
||||||
switch_buffer_write(context->audio_buffer, buf, bytes - inuse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue