static int output_configure(AACContext *ac,

                            uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags,

                            enum OCStatus oc_type, int get_new_frame)

{

    AVCodecContext *avctx = ac->avctx;

    int i, channels = 0, ret;

    uint64_t layout = 0;

    uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }};

    uint8_t type_counts[TYPE_END] = { 0 };



    if (ac->oc[1].layout_map != layout_map) {

        memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));

        ac->oc[1].layout_map_tags = tags;


    for (i = 0; i < tags; i++) {

        int type =         layout_map[i][0];

        int id =           layout_map[i][1];

        id_map[type][id] = type_counts[type]++;






    // Try to sniff a reasonable channel order, otherwise output the

    // channels in the order the PCE declared them.

    if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)

        layout = sniff_channel_order(layout_map, tags);

    for (i = 0; i < tags; i++) {

        int type =     layout_map[i][0];

        int id =       layout_map[i][1];

        int iid =      id_map[type][id];

        int position = layout_map[i][2];

        // Allocate or free elements depending on if they are in the

        // current program configuration.

        ret = che_configure(ac, position, type, iid, &channels);

        if (ret < 0)

            return ret;

        ac->tag_che_map[type][id] = ac->che[type][iid];


    if (ac->oc[1].m4ac.ps == 1 && channels == 2) {

        if (layout == AV_CH_FRONT_CENTER) {

            layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;

        } else {

            layout = 0;





    if (layout) avctx->channel_layout = layout;

                            ac->oc[1].channel_layout = layout;

    avctx->channels       = ac->oc[1].channels       = channels;

    ac->oc[1].status = oc_type;



    if (get_new_frame) {

        if ((ret = frame_configure_elements(ac->avctx)) < 0)

            return ret;




    return 0;

static int output_configure(AACContext *ac,

                            uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags,

                            enum OCStatus oc_type, int get_new_frame)

{

    AVCodecContext *avctx = ac->avctx;

    int i, channels = 0, ret;

    uint64_t layout = 0;

    uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }};

    uint8_t type_counts[TYPE_END] = { 0 };



    if (ac->oc[1].layout_map != layout_map) {

        memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));

        ac->oc[1].layout_map_tags = tags;


    for (i = 0; i < tags; i++) {

        int type =         layout_map[i][0];

        int id =           layout_map[i][1];

        id_map[type][id] = type_counts[type]++;






    

    

    if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)

        layout = sniff_channel_order(layout_map, tags);

    for (i = 0; i < tags; i++) {

        int type =     layout_map[i][0];

        int id =       layout_map[i][1];

        int iid =      id_map[type][id];

        int position = layout_map[i][2];

        

        

        ret = che_configure(ac, position, type, iid, &channels);

        if (ret < 0)

            return ret;

        ac->tag_che_map[type][id] = ac->che[type][iid];


    if (ac->oc[1].m4ac.ps == 1 && channels == 2) {

        if (layout == AV_CH_FRONT_CENTER) {

            layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;

        } else {

            layout = 0;





    if (layout) avctx->channel_layout = layout;

                            ac->oc[1].channel_layout = layout;

    avctx->channels       = ac->oc[1].channels       = channels;

    ac->oc[1].status = oc_type;



    if (get_new_frame) {

        if ((ret = frame_configure_elements(ac->avctx)) < 0)

            return ret;




    return 0;

static int FUNC_0(AACContext *VAR_0,

                            uint8_t VAR_1[MAX_ELEM_ID * 4][3], int VAR_2,

                            enum OCStatus VAR_3, int VAR_4)

{

    AVCodecContext *avctx = VAR_0->avctx;

    int VAR_5, VAR_6 = 0, VAR_7;

    uint64_t layout = 0;

    uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }};

    uint8_t type_counts[TYPE_END] = { 0 };



    if (VAR_0->oc[1].VAR_1 != VAR_1) {

        memcpy(VAR_0->oc[1].VAR_1, VAR_1, VAR_2 * sizeof(VAR_1[0]));

        VAR_0->oc[1].layout_map_tags = VAR_2;


    for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {

        int VAR_10 =         VAR_1[VAR_5][0];

        int VAR_10 =           VAR_1[VAR_5][1];

        id_map[VAR_10][VAR_10] = type_counts[VAR_10]++;






    

    

    if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)

        layout = sniff_channel_order(VAR_1, VAR_2);

    for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {

        int VAR_10 =     VAR_1[VAR_5][0];

        int VAR_10 =       VAR_1[VAR_5][1];

        int VAR_10 =      id_map[VAR_10][VAR_10];

        int VAR_11 = VAR_1[VAR_5][2];

        

        

        VAR_7 = che_configure(VAR_0, VAR_11, VAR_10, VAR_10, &VAR_6);

        if (VAR_7 < 0)

            return VAR_7;

        VAR_0->tag_che_map[VAR_10][VAR_10] = VAR_0->che[VAR_10][VAR_10];


    if (VAR_0->oc[1].m4ac.ps == 1 && VAR_6 == 2) {

        if (layout == AV_CH_FRONT_CENTER) {

            layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;

        } else {

            layout = 0;





    if (layout) avctx->channel_layout = layout;

                            VAR_0->oc[1].channel_layout = layout;

    avctx->VAR_6       = VAR_0->oc[1].VAR_6       = VAR_6;

    VAR_0->oc[1].status = VAR_3;



    if (VAR_4) {

        if ((VAR_7 = frame_configure_elements(VAR_0->avctx)) < 0)

            return VAR_7;




    return 0;

static int FUNC_0(AACContext *VAR_0,
uint8_t VAR_1[MAX_ELEM_ID * 4][3], int VAR_2,
enum OCStatus VAR_3, int VAR_4)
{ AVCodecContext *avctx = VAR_0->avctx; int VAR_5, VAR_6 = 0, VAR_7; uint64_t layout = 0; uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }}; uint8_t type_counts[TYPE_END] = { 0 }; if (VAR_0->oc[1].VAR_1 != VAR_1) { memcpy(VAR_0->oc[1].VAR_1, VAR_1, VAR_2 * sizeof(VAR_1[0])); VAR_0->oc[1].layout_map_tags = VAR_2; for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { int VAR_10 =         VAR_1[VAR_5][0]; int VAR_10 =           VAR_1[VAR_5][1]; id_map[VAR_10][VAR_10] = type_counts[VAR_10]++; if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)
layout = sniff_channel_order(VAR_1, VAR_2); for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { int VAR_10 =     VAR_1[VAR_5][0]; int VAR_10 =       VAR_1[VAR_5][1]; int VAR_10 =      id_map[VAR_10][VAR_10]; int VAR_11 = VAR_1[VAR_5][2]; VAR_7 = che_configure(VAR_0, VAR_11, VAR_10, VAR_10, &VAR_6); if (VAR_7 < 0)
return VAR_7; VAR_0->tag_che_map[VAR_10][VAR_10] = VAR_0->che[VAR_10][VAR_10]; if (VAR_0->oc[1].m4ac.ps == 1 && VAR_6 == 2) { if (layout == AV_CH_FRONT_CENTER) { layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT; } else { layout = 0; if (layout) avctx->channel_layout = layout; VAR_0->oc[1].channel_layout = layout; avctx->VAR_6       = VAR_0->oc[1].VAR_6       = VAR_6; VAR_0->oc[1].status = VAR_3; if (VAR_4) { if ((VAR_7 = frame_configure_elements(VAR_0->avctx)) < 0)
return VAR_7; return 0;