* @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 */
| 1023 | * 1 if there are additional frames |
| 1024 | */ |
| 1025 | static 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; |
no test coverage detected