Changeset 2aa6ed9b67b83743c36baed75e1e6b56e91284dc
- Timestamp:
- 06/11/08 16:57:23
(3 months ago)
- Author:
- Rafaël Carré <rcarre@m2x.nl>
- git-committer:
- Rafaël Carré <rcarre@m2x.nl> 1213196243 +0200
- git-parent:
[03ec97b0f1e272d2a247571415d9bc0e03d0add2]
- git-author:
- Rafaël Carré <rcarre@m2x.nl> 1213196243 +0200
- Message:
FFmpeg encoder : be sure to use the minimum required buffer size
Use the correct type for the buffer
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf7d5f3e |
r2aa6ed9 |
|
| 107 | 107 | */ |
|---|
| 108 | 108 | char *p_buffer; |
|---|
| 109 | | char *p_buffer_out; |
|---|
| | 109 | uint8_t *p_buffer_out; |
|---|
| | 110 | size_t i_buffer_out; |
|---|
| 110 | 111 | |
|---|
| 111 | 112 | /* |
|---|
| … | … | |
| 264 | 265 | p_enc->pf_encode_audio = EncodeAudio; |
|---|
| 265 | 266 | |
|---|
| | 267 | p_sys->p_buffer = NULL; |
|---|
| 266 | 268 | p_sys->p_buffer_out = NULL; |
|---|
| 267 | | p_sys->p_buffer = NULL; |
|---|
| | 269 | p_sys->i_buffer_out = 0; |
|---|
| 268 | 270 | |
|---|
| 269 | 271 | p_sys->p_context = p_context = avcodec_alloc_context(); |
|---|
| … | … | |
| 459 | 461 | i_aspect_den * (int64_t)p_context->width, 1 << 30 ); |
|---|
| 460 | 462 | |
|---|
| 461 | | p_sys->p_buffer_out = malloc( p_context->height * p_context->width * 3 ); |
|---|
| | 463 | p_sys->i_buffer_out = p_context->height * p_context->width * 3; |
|---|
| | 464 | if( p_sys->i_buffer_out < FF_MIN_BUFFER_SIZE ) |
|---|
| | 465 | p_sys->i_buffer_out = FF_MIN_BUFFER_SIZE; |
|---|
| | 466 | p_sys->p_buffer_out = malloc( p_sys->i_buffer_out ); |
|---|
| 462 | 467 | |
|---|
| 463 | 468 | p_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0'); |
|---|
| … | … | |
| 687 | 692 | if( p_enc->fmt_in.i_cat == AUDIO_ES ) |
|---|
| 688 | 693 | { |
|---|
| 689 | | p_sys->p_buffer_out = malloc( 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE ); |
|---|
| | 694 | p_sys->i_buffer_out = 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE; |
|---|
| | 695 | p_sys->p_buffer_out = malloc( p_sys->i_buffer_out ); |
|---|
| 690 | 696 | p_sys->i_frame_size = p_context->frame_size * 2 * p_context->channels; |
|---|
| 691 | 697 | p_sys->p_buffer = malloc( p_sys->i_frame_size ); |
|---|
| … | … | |
| 903 | 909 | /* End work-around */ |
|---|
| 904 | 910 | |
|---|
| 905 | | i_out = avcodec_encode_video( p_sys->p_context, (uint8_t*)p_sys->p_buffer_out, |
|---|
| 906 | | p_sys->p_context->height * p_sys->p_context->width * 3, &frame ); |
|---|
| | 911 | i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out, |
|---|
| | 912 | p_sys->i_buffer_out, &frame ); |
|---|
| 907 | 913 | |
|---|
| 908 | 914 | if( i_out > 0 ) |
|---|
| … | … | |
| 1025 | 1031 | } |
|---|
| 1026 | 1032 | |
|---|
| 1027 | | i_out = avcodec_encode_audio( p_sys->p_context, |
|---|
| 1028 | | (uint8_t *)p_sys->p_buffer_out, |
|---|
| 1029 | | 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE, |
|---|
| 1030 | | p_samples ); |
|---|
| | 1033 | i_out = avcodec_encode_audio( p_sys->p_context, p_sys->p_buffer_out, |
|---|
| | 1034 | p_sys->i_buffer_out, p_samples ); |
|---|
| 1031 | 1035 | |
|---|
| 1032 | 1036 | #if 0 |
|---|