Revision 6d263f41 libavcodec/flacenc.c

View differences:

libavcodec/flacenc.c
1101 1101
}
1102 1102

  
1103 1103

  
1104
static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub)
1105
{
1106
    put_sbits(&s->pb, sub->obits, sub->residual[0]);
1107

  
1108
    if (sub->type == FLAC_SUBFRAME_VERBATIM) {
1109
        int i;
1110
        for (i = 0; i < s->frame.blocksize; i++)
1111
            put_sbits(&s->pb, sub->obits, sub->residual[i]);
1112
    }
1113
}
1114

  
1115

  
1116
static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
1104
static void output_subframe(FlacEncodeContext *s, FlacSubframe *sub)
1117 1105
{
1118 1106
    int i, p, porder, psize;
1119
    int32_t *res, *part_end, *frame_end;
1120

  
1107
    int32_t *part_end;
1108
    int32_t *res       =  sub->residual;
1109
    int32_t *frame_end = &sub->residual[s->frame.blocksize];
1110

  
1111
    if (sub->type == FLAC_SUBFRAME_CONSTANT) {
1112
        put_sbits(&s->pb, sub->obits, res[0]);
1113
    } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {
1114
        while (res < frame_end)
1115
            put_sbits(&s->pb, sub->obits, *res++);
1116
    } else {
1121 1117
    /* warm-up samples */
1122
    res = sub->residual;
1123 1118
    for (i = 0; i < sub->order; i++)
1124 1119
        put_sbits(&s->pb, sub->obits, *res++);
1125 1120

  
......
1142 1137

  
1143 1138
    /* residual */
1144 1139
    part_end  = &sub->residual[psize             ];
1145
    frame_end = &sub->residual[s->frame.blocksize];
1146 1140
    for (p = 0; p < 1 << porder; p++) {
1147 1141
        int k = sub->rc.params[p];
1148 1142
        put_bits(&s->pb, 4, k);
......
1150 1144
            set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0);
1151 1145
        part_end = FFMIN(frame_end, part_end + psize);
1152 1146
    }
1147
    }
1153 1148
}
1154 1149

  
1155 1150

  
......
1170 1165
        put_bits(&s->pb, 1, 0); /* no wasted bits */
1171 1166

  
1172 1167
        /* subframe */
1173
        switch (sub->type) {
1174
        case FLAC_SUBFRAME_CONSTANT:
1175
        case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break;
1176
        case FLAC_SUBFRAME_FIXED:
1177
        case FLAC_SUBFRAME_LPC:      output_subframe_lpc(     s, sub); break;
1178
        }
1168
        output_subframe(s, sub);
1179 1169
    }
1180 1170
}
1181 1171

  

Also available in: Unified diff