MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_frame

Function decode_frame

libavcodec/wmalosslessdec.c:1025–1120  ·  view source on GitHub ↗

* @brief Decode one WMA frame. * @param s codec context * @return 0 if the trailer bit indicates that this is the last frame, * 1 if there are additional frames */

Source from the content-addressed store, hash-verified

1023 * 1 if there are additional frames
1024 */
1025static int decode_frame(WmallDecodeCtx *s)
1026{
1027 GetBitContext* gb = &s->gb;
1028 int more_frames = 0, len = 0, i, ret;
1029
1030 s->frame->nb_samples = s->samples_per_frame;
1031 if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) {
1032 /* return an error if no frame could be decoded at all */
1033 s->packet_loss = 1;
1034 s->frame->nb_samples = 0;
1035 return ret;
1036 }
1037 for (i = 0; i < s->num_channels; i++) {
1038 s->samples_16[i] = (int16_t *)s->frame->extended_data[i];
1039 s->samples_32[i] = (int32_t *)s->frame->extended_data[i];
1040 }
1041
1042 /* get frame length */
1043 if (s->len_prefix)
1044 len = get_bits(gb, s->log2_frame_size);
1045
1046 /* decode tile information */
1047 if ((ret = decode_tilehdr(s))) {
1048 s->packet_loss = 1;
1049 av_frame_unref(s->frame);
1050 return ret;
1051 }
1052
1053 /* read drc info */
1054 if (s->dynamic_range_compression)
1055 s->drc_gain = get_bits(gb, 8);
1056
1057 /* no idea what these are for, might be the number of samples
1058 that need to be skipped at the beginning or end of a stream */
1059 if (get_bits1(gb)) {
1060 av_unused int skip;
1061
1062 /* usually true for the first frame */
1063 if (get_bits1(gb)) {
1064 skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
1065 ff_dlog(s->avctx, "start skip: %i\n", skip);
1066 }
1067
1068 /* sometimes true for the last frame */
1069 if (get_bits1(gb)) {
1070 skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
1071 ff_dlog(s->avctx, "end skip: %i\n", skip);
1072 s->frame->nb_samples -= skip;
1073 if (s->frame->nb_samples <= 0)
1074 return AVERROR_INVALIDDATA;
1075 }
1076
1077 }
1078
1079 /* reset subframe states */
1080 s->parsed_all_subframes = 0;
1081 for (i = 0; i < s->num_channels; i++) {
1082 s->channel[i].decoded_samples = 0;

Callers 1

decode_packetFunction · 0.70

Calls 10

ff_get_bufferFunction · 0.85
av_frame_unrefFunction · 0.85
get_bits1Function · 0.85
av_log2Function · 0.85
get_bits_countFunction · 0.85
av_logFunction · 0.85
skip_bits_longFunction · 0.85
get_bitsFunction · 0.70
decode_tilehdrFunction · 0.70
decode_subframeFunction · 0.70

Tested by

no test coverage detected