mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 09:40:18 +00:00
audio decompress: pass packet list (iterator)
This commit is contained in:
@@ -44,9 +44,9 @@
|
||||
#include "audio/codec.h"
|
||||
#include "audio/utils.h"
|
||||
#include "debug.h"
|
||||
#include "utils/misc.h"
|
||||
|
||||
#include "lib_common.h"
|
||||
#include "utils/misc.h"
|
||||
#include "utils/packet_counter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
@@ -276,7 +276,9 @@ audio_frame2 audio_codec_compress(struct audio_codec_state *s, const audio_frame
|
||||
return res;
|
||||
}
|
||||
|
||||
audio_frame2 audio_codec_decompress(struct audio_codec_state *s, audio_frame2 *frame)
|
||||
audio_frame2
|
||||
audio_codec_decompress(struct audio_codec_state *s, audio_frame2 *frame,
|
||||
packet_counter *counter)
|
||||
{
|
||||
if (s->state_count < frame->get_channel_count()) {
|
||||
s->state = (void **) realloc(s->state, sizeof(void *) * frame->get_channel_count());
|
||||
@@ -307,7 +309,8 @@ audio_frame2 audio_codec_decompress(struct audio_codec_state *s, audio_frame2 *f
|
||||
if (channel.data_len == 0) {
|
||||
continue;
|
||||
}
|
||||
audio_channel *out = s->funcs->decompress(s->state[i], &channel);
|
||||
struct packet_iterator it = { counter, i, 0 };
|
||||
audio_channel *out = s->funcs->decompress(s->state[i], &channel, &it);
|
||||
if (out) {
|
||||
if (!out_frame_initialized) {
|
||||
ret.init(frame->get_channel_count(), AC_PCM, out->bps, out->sample_rate);
|
||||
|
||||
@@ -47,11 +47,14 @@ typedef enum {
|
||||
AUDIO_DECODER
|
||||
} audio_codec_direction_t;
|
||||
|
||||
struct packet_counter;
|
||||
struct packet_iterator;
|
||||
|
||||
struct audio_compress_info {
|
||||
const audio_codec_t *supported_codecs;
|
||||
void *(*init)(audio_codec_t, audio_codec_direction_t, bool, int bitrate);
|
||||
audio_channel *(*compress)(void *, audio_channel *);
|
||||
audio_channel *(*decompress)(void *, audio_channel *);
|
||||
audio_channel *(*decompress)(void *, audio_channel *, struct packet_iterator *);
|
||||
const int *(*get_samplerates)(void *);
|
||||
void (*done)(void *);
|
||||
};
|
||||
@@ -77,8 +80,9 @@ struct audio_codec_state *audio_codec_init_cfg(const char *audio_codec_cfg, audi
|
||||
struct audio_codec_state *audio_codec_reconfigure(struct audio_codec_state *old,
|
||||
audio_codec_t audio_codec, audio_codec_direction_t);
|
||||
audio_frame2 audio_codec_compress(struct audio_codec_state *, const audio_frame2 *);
|
||||
audio_frame2 audio_codec_decompress(struct audio_codec_state *, audio_frame2 *);
|
||||
const int *audio_codec_get_supported_samplerates(struct audio_codec_state *);
|
||||
audio_frame2 audio_codec_decompress(struct audio_codec_state *, audio_frame2 *,
|
||||
packet_counter *);
|
||||
const int *audio_codec_get_supported_samplerates(struct audio_codec_state *);
|
||||
void audio_codec_done(struct audio_codec_state *);
|
||||
|
||||
std::vector<std::pair<audio_codec_info_t, bool>> get_audio_codec_list();
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
static void *dummy_pcm_init(audio_codec_t audio_codec, audio_codec_direction_t direction, bool try_init,
|
||||
int bitrate);
|
||||
static audio_channel *dummy_pcm_compress(void *, audio_channel *);
|
||||
static audio_channel *dummy_pcm_decompress(void *, audio_channel *);
|
||||
static void dummy_pcm_done(void *);
|
||||
|
||||
struct dummy_pcm_codec_state {
|
||||
@@ -79,8 +78,11 @@ static audio_channel *dummy_pcm_compress(void *state, audio_channel * channel)
|
||||
return channel;
|
||||
}
|
||||
|
||||
static audio_channel *dummy_pcm_decompress(void *state, audio_channel * channel)
|
||||
static audio_channel *
|
||||
dummy_pcm_decompress(void *state, audio_channel *channel,
|
||||
struct packet_iterator *it)
|
||||
{
|
||||
UNUSED(it);
|
||||
struct dummy_pcm_codec_state *s = (struct dummy_pcm_codec_state *) state;
|
||||
assert(s->magic == MAGIC);
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ struct libavcodec_codec_state;
|
||||
static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t direction,
|
||||
bool silent, int bitrate);
|
||||
static audio_channel *libavcodec_compress(void *, audio_channel *);
|
||||
static audio_channel *libavcodec_decompress(void *, audio_channel *);
|
||||
static void libavcodec_done(void *);
|
||||
static void cleanup_common(struct libavcodec_codec_state *s);
|
||||
|
||||
@@ -532,8 +531,11 @@ static audio_channel *libavcodec_compress(void *state, audio_channel * channel)
|
||||
}
|
||||
}
|
||||
|
||||
static audio_channel *libavcodec_decompress(void *state, audio_channel * channel)
|
||||
static audio_channel *
|
||||
libavcodec_decompress(void *state, audio_channel *channel,
|
||||
struct packet_iterator *it)
|
||||
{
|
||||
UNUSED(it);
|
||||
struct libavcodec_codec_state *s = (struct libavcodec_codec_state *) state;
|
||||
assert(channel->data_len > 0);
|
||||
assert(s->magic == MAGIC);
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -772,7 +773,9 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st
|
||||
}
|
||||
|
||||
s->frame_size = received_frame.get_data_len();
|
||||
audio_frame2 decompressed = audio_codec_decompress(decoder->audio_decompress, &received_frame);
|
||||
audio_frame2 decompressed =
|
||||
audio_codec_decompress(decoder->audio_decompress, &received_frame,
|
||||
decoder->packet_counter);
|
||||
if (!decompressed) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ struct packet_counter;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct packet_iterator {
|
||||
struct packet_counter *counter;
|
||||
int channel;
|
||||
int first_packet;
|
||||
};
|
||||
|
||||
struct packet_counter *packet_counter_init(int num_substreams);
|
||||
void packet_counter_destroy(struct packet_counter *state);
|
||||
void packet_counter_register_packet(struct packet_counter *state, unsigned int substream_id,
|
||||
|
||||
Reference in New Issue
Block a user