sonic: update to encode2() API
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		
							parent
							
								
									4cdc337b5d
								
							
						
					
					
						commit
						a44cbc1cbc
					
				@ -21,6 +21,7 @@
 | 
				
			|||||||
#include "avcodec.h"
 | 
					#include "avcodec.h"
 | 
				
			||||||
#include "get_bits.h"
 | 
					#include "get_bits.h"
 | 
				
			||||||
#include "golomb.h"
 | 
					#include "golomb.h"
 | 
				
			||||||
 | 
					#include "internal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @file
 | 
					 * @file
 | 
				
			||||||
@ -622,15 +623,19 @@ static av_cold int sonic_encode_close(AVCodecContext *avctx)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int sonic_encode_frame(AVCodecContext *avctx,
 | 
					static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 | 
				
			||||||
                            uint8_t *buf, int buf_size, void *data)
 | 
					                              const AVFrame *frame, int *got_packet_ptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    SonicContext *s = avctx->priv_data;
 | 
					    SonicContext *s = avctx->priv_data;
 | 
				
			||||||
    PutBitContext pb;
 | 
					    PutBitContext pb;
 | 
				
			||||||
    int i, j, ch, quant = 0, x = 0;
 | 
					    int i, j, ch, quant = 0, x = 0;
 | 
				
			||||||
    short *samples = data;
 | 
					    int ret;
 | 
				
			||||||
 | 
					    const short *samples = (const int16_t*)frame->data[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    init_put_bits(&pb, buf, buf_size*8);
 | 
					    if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size * 5 + 1000)))
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    init_put_bits(&pb, avpkt->data, avpkt->size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // short -> internal
 | 
					    // short -> internal
 | 
				
			||||||
    for (i = 0; i < s->frame_size; i++)
 | 
					    for (i = 0; i < s->frame_size; i++)
 | 
				
			||||||
@ -741,7 +746,9 @@ static int sonic_encode_frame(AVCodecContext *avctx,
 | 
				
			|||||||
//    av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8);
 | 
					//    av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flush_put_bits(&pb);
 | 
					    flush_put_bits(&pb);
 | 
				
			||||||
    return (put_bits_count(&pb)+7)/8;
 | 
					    avpkt->size = (put_bits_count(&pb)+7)/8;
 | 
				
			||||||
 | 
					    *got_packet_ptr = 1;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */
 | 
					#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -972,7 +979,7 @@ AVCodec ff_sonic_encoder = {
 | 
				
			|||||||
    .id             = AV_CODEC_ID_SONIC,
 | 
					    .id             = AV_CODEC_ID_SONIC,
 | 
				
			||||||
    .priv_data_size = sizeof(SonicContext),
 | 
					    .priv_data_size = sizeof(SonicContext),
 | 
				
			||||||
    .init           = sonic_encode_init,
 | 
					    .init           = sonic_encode_init,
 | 
				
			||||||
    .encode         = sonic_encode_frame,
 | 
					    .encode2        = sonic_encode_frame,
 | 
				
			||||||
    .capabilities   = CODEC_CAP_EXPERIMENTAL,
 | 
					    .capabilities   = CODEC_CAP_EXPERIMENTAL,
 | 
				
			||||||
    .close          = sonic_encode_close,
 | 
					    .close          = sonic_encode_close,
 | 
				
			||||||
    .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
 | 
					    .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
 | 
				
			||||||
@ -986,7 +993,7 @@ AVCodec ff_sonic_ls_encoder = {
 | 
				
			|||||||
    .id             = AV_CODEC_ID_SONIC_LS,
 | 
					    .id             = AV_CODEC_ID_SONIC_LS,
 | 
				
			||||||
    .priv_data_size = sizeof(SonicContext),
 | 
					    .priv_data_size = sizeof(SonicContext),
 | 
				
			||||||
    .init           = sonic_encode_init,
 | 
					    .init           = sonic_encode_init,
 | 
				
			||||||
    .encode         = sonic_encode_frame,
 | 
					    .encode2        = sonic_encode_frame,
 | 
				
			||||||
    .capabilities   = CODEC_CAP_EXPERIMENTAL,
 | 
					    .capabilities   = CODEC_CAP_EXPERIMENTAL,
 | 
				
			||||||
    .close          = sonic_encode_close,
 | 
					    .close          = sonic_encode_close,
 | 
				
			||||||
    .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
 | 
					    .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user