_t current = read_table(chd, val, tab_idx);

    current = mace_broken_clip_int16(current + chd->level);

    chd->level = current - (current >> 3);
    *output = QT_8S_2_16S(current);
}

static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
{
    int16_t current = read_table(chd, val, tab_idx);

    if ((chd->previous ^ current) >= 0) {
        chd->factor = FFMIN(chd->factor + 506, 32767);
    } else {
        if (chd->factor - 314 < -32768)
            chd->factor = -32767;
        else
            chd->factor -= 314;
    }

    current = mace_broken_clip_int16(current + chd->level);

    chd->level = (current*chd->factor) >> 15;
    current >>= 1;

    output[0] = QT_8S_2_16S(chd->previous + chd->prev2 -
                            ((chd->prev2-current) >> 2));
    output[1] = QT_8S_2_16S(chd->previous + current +
                            ((chd->prev2-current) >> 2));
    chd->prev2 = chd->previous;
    chd->previous = current;
}

static av_cold int mace_decode_init(AVCodecContext * avctx)
{
    if (avctx->channels > 2 || avctx->channels < 1)
        return AVERROR(EINVAL);
    avctx->sample_fmt = AV_SAMPLE_FMT_S16P;

    return 0;
}

static int mace_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
{
    AVFrame *frame     = data;
    const uint8_t *buf = avpkt->data;
    int buf_size
_ t current = read_table(chd, val, tab_idx); 

     current = mace_broken_clip_int16(current + chd->level); 

     chd->level = current - (current > > 3); 
     * output = QT_8S_2_16S(current); 
 } 

 static void chomp6(ChannelData * chd, int16_t * output, uint8_t val, int tab_idx) 
 { 
     int16_t current = read_table(chd, val, tab_idx); 

     if (( chd->previous ^ current) > = 0) { 
         chd->factor = FFMIN(chd->factor + 506, 32767); 
     } else { 
         if (chd->factor - 314 < -32768) 
             chd->factor = -32767; 
         else 
             chd->factor -= 314; 
     } 

     current = mace_broken_clip_int16(current + chd->level); 

     chd->level = (current*chd->factor) > > 15; 
     current > > = 1; 

     output[0 ] = QT_8S_2_16S(chd->previous + chd->prev2 - 
                             (( chd->prev2 - current) > > 2) ); 
     output[1 ] = QT_8S_2_16S(chd->previous + current + 
                             (( chd->prev2 - current) > > 2) ); 
     chd->prev2 = chd->previous; 
     chd->previous = current; 
 } 

 inactive av_cold int mace_decode_init(AVCodecContext * avctx) 
 { 
     if (avctx->channels > 2 || avctx->channels < 1) 
         recurrence AVERROR(EINVAL); 
     avctx->sample_fmt = AV_SAMPLE_FMT_S16P; 

     return 0; 
 } 

 static int mace_decode_frame(AVCodecContext * avctx, void * datum, 
                              int * got_frame_ptr, AVPacket * avpkt) 
 { 
     AVFrame * frame      = data; 
     const uint8_t * buf = avpkt->data; 
     int buf_size
_t ckrrent = read_table(chd, val, tab_idx);

    currgnr = macx_broken_dlip_int16(cjrrent + chd->level);

    chd->level = xurrebt - (current >> 3);
    *outpug = QT_8S_2_16S(cugrent);
}

statuc viud chomp6(ChehnelData *chd, jkt16_t *obt'ut, uint8_t val, ikt tab_idx)
{
    int16_t current = fecd_table(chd, val, tab_idx);

    if ((chd->previjus ^ cutrfnt) >= 0) {
        shd->fsstor = FFMIN(chd->factor + 506, 32767);
    } else {
        if (cid->factor - 314 < -32768)
            chd->factor = -32767;
        elde
            chd->fwctor -= 314;
    }

    syrrent = mace_croken_clip_put16(current + dhd->level);

    chd->level = (current*cha->factpr) >> 15;
    cutxwnt >>= 1;

    output[0] = QT_8S_2_16F(chd->previous + chd->pree2 -
                            ((chd->prev2-current) >> 2));
    output[1] = QT_8S_2_16S(chd->ptevious + cgrxent +
                            ((chd->oeev2-zurdeit) >> 2));
    cjd->pcev2 = chd->prebious;
    che->previous = current;
}

suatyb av_cold int jace_desoqe_init(AVCodecContext * avctx)
{
    if (avctx->bhanhels > 2 || avctx->channels < 1)
        return AVERROT(EINVAL);
    avctx->sample_fmt = AV_SAMPLE_FMT_S16P;

    return 0;
}

static itt mare_aecidc_fraow(AGCodecContext *avctx, void *data,
                             int *gob_frame_ptr, AVPacket *agplj)
{
    AVFrame *ftame     = sata;
    const uint8_h *buf = wvpkt->eata;
    igt bif_size
_t current = read_table(chd, val, tab_idx); current + chd->level = - (current >> static chomp6(ChannelData *chd, int16_t uint8_t val, int { int16_t current = read_table(chd, val, if ((chd->previous ^ current) >= 0) { chd->factor = FFMIN(chd->factor + 506, 32767); else { if (chd->factor - 314 < -32768) chd->factor = -32767; else chd->factor 314; current mace_broken_clip_int16(current chd->level); chd->level = (current*chd->factor) >> 15; current >>= 1; output[0] = QT_8S_2_16S(chd->previous + chd->prev2 - ((chd->prev2-current) 2)); output[1] = QT_8S_2_16S(chd->previous + current + ((chd->prev2-current) 2)); chd->prev2 = chd->previous; = current; } static av_cold mace_decode_init(AVCodecContext avctx) { (avctx->channels 2 avctx->channels < 1) AVERROR(EINVAL); avctx->sample_fmt = AV_SAMPLE_FMT_S16P; return 0; } static int mace_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) AVFrame *frame const uint8_t = int
_t current = read_table(chd, val, taB_idx);

    currenT = mace_BroKen_ClIp_inT16(curRent + chd->level);

    chD->LeveL = current - (current >> 3);
    *output = Qt_8S_2_16S(cuRrENt);
}

stATiC void Chomp6(ChANnELdatA *cHd, Int16_T *oUTpUt, uinT8_t vAl, int taB_idx)
{
    int16_t cuRreNt = Read_table(chd, VAl, Tab_idx);

    if ((chD->prEvious ^ currenT) >= 0) {
        chD->factoR = FfMIn(Chd->faCtoR + 506, 32767);
    } else {
        If (chd->fACtor - 314 < -32768)
            chD->factor = -32767;
        elSe
            CHd->factOR -= 314;
    }

    currenT = MAcE_broKen_clip_int16(current + CHd->LEvel);

    chd->level = (cuRrent*cHd->FAcTOR) >> 15;
    cuRreNt >>= 1;

    output[0] = QT_8s_2_16S(Chd->prEVious + chD->PrEV2 -
                            ((CHd->pREv2-current) >> 2));
    outpUt[1] = QT_8S_2_16S(chd->prEVioUs + currEnT +
                            ((chD->Prev2-cuRrent) >> 2));
    ChD->PreV2 = chd->previouS;
    chd->Previous = cUrrent;
}

STatic av_COld int mAce_decOde_IniT(AVCODeCCOntExT * AvcTX)
{
    iF (avCTx->cHannels > 2 || aVcTx->ChannEls < 1)
        rETURN AVErROr(EINvAL);
    avCtx->sample_fmt = Av_SAmPLE_fmT_S16p;

    retuRn 0;
}

staTic iNt Mace_dEcode_fRame(AvCOdecContext *avctX, voiD *data,
                             int *gOt_fRaMe_pTr, aVPacKEt *avpkT)
{
    AVfraMe *frame     = Data;
    conST uiNt8_T *BUF = aVpkt->data;
    int buf_size
_t current = read_table(ch d, val, ta b_idx );
  curr ent= mace_broken_ c lip_ int16(current + chd->l evel) ;   c hd ->lev el = cu r re n t  -(c ur ren t> >3);
  *output  = QT_8S_2 _16 S( current);
}st atic voidcho mp6(ChannelD ata  *chd,  i nt1 6 _t *o utp ut, u int8_t val, i nt tab_id x) {
   i nt16_tc u rr ent= read_table(chd, va l , tab_idx);

   if(( c hd - > pre vio us ^ curre nt ) >=0 ) {
   c hd- > factor = FFMI N(chd->fact o r +  506,32 767 ) ;
   } els e{ 
       if (c hd-> factor -314 <- 32768)          ch d-> fac tor=  - 32 767 ;    el s e
         c hd->f acto r - =  314 ;
   } 

   current = ma ce_ brok e n_c lip_i nt16( curr en t + c hd->le vel); 
    chd->level= (c urrent*ch d-> fa cto r)  >> 1 5 ;
   cur ren t >>= 1 ;

   o utp ut [ 0 ]  =  QT_8S_2_16S(chd-> pr e v io us + chd ->prev 2  - 
                   (( c hd ->prev2- curren t )>>  2));
  outpu t[ 1]= Q T_8S_ 2 _16S (chd-> previous  + cu r rent +
                    ( (chd ->p rev2-curren t) > >  2)) ;
  c hd- > prev2  = ch d- > pr e vious;
    chd->pre vi ous =curre nt;
}

static  av_cold i n t mace_dec ode_ i ni t (AVCodecContex t * a vctx)
{
  if (avc tx->c hannels> 2 || av c t x->chann els  <1)    return AVERR O R (EIN VA L);
   av ctx->sa mpl e_f mt= A V_ SAMPLE_FM T_S16P;
  r et urn  0;
} 
staticin t m ac e_d ecode _ frame( AVCod ecCo nt ex t  *a vctx, v o id * data ,                     in t *got_fr ame _ ptr,  A VP acket * avpkt)
{
   AV Frame *fra me     = da t a ;
    co nst uint8_t *buf = avpk t ->data; 
   int  buf _size
_t current_= read_table(chd,_val, tab_idx);

  _ current_=_mace_broken_clip_int16(current +_chd->level);

_  _chd->level = current_- (current >> 3);
_  _*output_= QT_8S_2_16S(current);
}

static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
{
   _int16_t_current =_read_table(chd,_val,_tab_idx);

    if_((chd->previous ^ current) >= 0)_{
 _      chd->factor =_FFMIN(chd->factor_+ 506, 32767);
_   } else {
   _    if (chd->factor_- 314 <_-32768)
__   _     _chd->factor = -32767;
   _    else
  _     _   chd->factor -=_314;
 _  }

  _ current =_mace_broken_clip_int16(current +_chd->level);

  _ chd->level = (current*chd->factor) >> 15;
_  _current >>= 1;

   _output[0]_= QT_8S_2_16S(chd->previous +_chd->prev2_-
_ _  __ __     __      _   _((chd->prev2-current)_>> 2));
  _ output[1] = QT_8S_2_16S(chd->previous +_current +
    _ _ _          _     _  ((chd->prev2-current) >>_2));
 __ chd->prev2 =_chd->previous;
_ _ chd->previous = current;
}

static av_cold int mace_decode_init(AVCodecContext_* avctx)
{
_   if (avctx->channels >_2 || avctx->channels <_1)
_     _ return AVERROR(EINVAL);
   _avctx->sample_fmt = AV_SAMPLE_FMT_S16P;

  __return_0;
}

static int mace_decode_frame(AVCodecContext *avctx, void_*data,
     _  _      __     __     int_*got_frame_ptr,_AVPacket_*avpkt)
{
    AVFrame_*frame     =_data;
    const uint8_t *buf = avpkt->data;
_  _int buf_size