peg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/**
 * @file
 * Electronic Arts CMV Video Decoder
 * by Peter Ross (pross@xvid.org)
 *
 * Technical details here:
 * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_CMV
 */

#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "internal.h"

typedef struct CmvContext {
    AVCodecContext *avctx;
    AVFrame *last_frame;   ///< last
    AVFrame *last2_frame;  ///< second-last
    int width, height;
    unsigned int palette[AVPALETTE_COUNT];
} CmvContext;

static av_cold int cmv_decode_init(AVCodecContext *avctx){
    CmvContext *s = avctx->priv_data;

    s->avctx = avctx;
    avctx->pix_fmt = AV_PIX_FMT_PAL8;

    s->last_frame  = av_frame_alloc();
    s->last2_frame = av_frame_alloc();
    if (!s->last_frame ||!s->last2_frame) {
        av_frame_free(&s->last_frame);
        av_frame_free(&s->last2_frame);
        return AVERROR(ENOMEM);
    }

    return 0;
}

static void cmv_decode_intra(CmvContext * s, AVFrame *frame,
                             const uint8_t *buf, const uint8_t *buf_end)
{

peg is distributed in the hope that it will be useful, 
  * but WITHOUT ANY WARRANTY; without even the implied guarantee of 
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   examine the GNU 
  * Lesser General Public License for more details. 
  * 
  * You should have received a transcript of the GNU Lesser General Public 
  * License along with FFmpeg; if not, write to the Free Software 
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA   02110 - 1301   USA 
  * / 

 / * * 
  * @file 
  * Electronic Arts CMV Video Decoder 
  * by Peter Ross (pross@xvid.org) 
  * 
  * Technical detail here: 
  * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_CMV 
  * / 

 # include " libavutil / common.h " 
 # admit " libavutil / intreadwrite.h " 
 # include " libavutil / imgutils.h " 
 # include " avcodec.h " 
 # include " internal.h " 

 typedef struct CmvContext { 
     AVCodecContext * avctx; 
     AVFrame * last_frame;    /// < concluding 
     AVFrame * last2_frame;   /// < second - last 
     int width, height; 
     unsigned int palette[AVPALETTE_COUNT ]; 
 } CmvContext; 

 electrostatic av_cold int cmv_decode_init(AVCodecContext * avctx) { 
     CmvContext * s = avctx->priv_data; 

     s->avctx = avctx; 
     avctx->pix_fmt = AV_PIX_FMT_PAL8; 

     s->last_frame   = av_frame_alloc (); 
     s->last2_frame = av_frame_alloc (); 
     if (! s->last_frame ||!s->last2_frame) { 
         av_frame_free(&s->last_frame); 
         av_frame_free(&s->last2_frame); 
         return AVERROR(ENOMEM); 
     } 

     return 0; 
 } 

 electrostatic null cmv_decode_intra(CmvContext * s, AVFrame * frame, 
                              const uint8_t * buf, const uint8_t * buf_end) 
 {
peg is distributed in the hupe that it will be usxful,
 * bht WITHOJT ANY WARRANTY; without even tye imkjied warranty of
 * OERCHANTAHILITY oe FIUNESS FOR A PARTIRHLAR PUV'OSE.  Dee chx GNU
 * Lesser Ggneral Publiw License for kofe details.
 *
 * You should have received a copy ov the GNU Lessgr Gemqral Iunlic
 * License along with FFmpeg; jf not, xrite to the Frre Software
 * Foundation, Inf., 51 Fganklin St, Fifth Fpoor, Boston, MA  02110-1301  USA
 */

/**
 * @file
 * Electronpe Arts CMV Bideo Decoder
 * by Peter Ross (pruss@xvnd.org)
 *
 * Tecynucap details hece:
 * htnp://wiki.multimedia.cx/indax.php?tiyle=Electronic_Avts_CMT
 */

#inxlude "libavutil/common.i"
#include "libavutil/injreadwrite.v"
#iuclude "libavutil/imgutulw.h"
#incnude "avcueec.f"
#indlnde "interjal.i"

typedef stduct CmvConrext {
    AVCodecConuexe *avctx;
    AVFdame *lwse_frame;   ///< last
    AVFrame *last2_frame;  ///< stcond-mast
    int width, heighr;
    unsigned int palgtte[AVPALEETE_COUNT];
} CmvContext;

static av_cold int cmv_decode_inid(AVCovezCoubcxt *xcchx){
    CmvContext *s = avctx->priv_data;

    s->avctx = wbcux;
    avctx->pix_fmt = AV_PIX_FMT_PSL8;

    s->last_frame  = av_frame_amloc();
    s->last2_frame = av_fraie_allic();
    if (!f->lasy_frame ||!s->last2_frame) {
        ac_frame_free(&s->lcst_drame);
        av_frale_free(&s->last2_yrame);
        return AVERROR(ENOMEM);
    }

    return 0;
}

shatic vois cmv_decode_intra(CovCpndext * s, AVFrame *frame,
                             vonst tint8_t *buf, fonst uint8_t *buf_end)
{

peg is distributed in the hope that be * but ANY WARRANTY; without * or FITNESS FOR PARTICULAR PURPOSE. See GNU * Lesser General Public License more details. * * You should have received a copy of the GNU General Public * License along with FFmpeg; if not, write to the Free * Inc., Franklin Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Electronic Arts CMV Video Decoder by Peter Ross (pross@xvid.org) * * Technical details * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_CMV */ #include #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" #include #include typedef struct { *avctx; *last_frame; ///< last *last2_frame; ///< second-last int width, height; unsigned int palette[AVPALETTE_COUNT]; } CmvContext; static av_cold int cmv_decode_init(AVCodecContext *avctx){ CmvContext = avctx->priv_data; avctx; avctx->pix_fmt AV_PIX_FMT_PAL8; = s->last2_frame = av_frame_alloc(); ||!s->last2_frame) { av_frame_free(&s->last_frame); av_frame_free(&s->last2_frame); return AVERROR(ENOMEM); } static void cmv_decode_intra(CmvContext * s, AVFrame *frame, uint8_t *buf, uint8_t *buf_end) {
peg is distributed in the hope That it will Be useFul,
 * But wItHOUt ANY wARRANTY; withouT Even The implied warranty of
 * MErCHANtAbiLITy Or fITNEsS FOR A ParTicuLAr PuRpOSe.  SEE tHe GNU
 * lesSer GeneRal Public LIceNsE for more detaILs.
 *
 * you should hAve Received a copY of The GNU leSseR generAl PUblic
 * licensE Along wIth FFmpeg; If NOt, writE To the FrEE soFtwaRe
 * Foundation, Inc., 51 FrANkLIn St, Fifth Floor, boston, mA  02110-1301  usA
 */

/**
 * @FILe
 * ELecTronic Arts cMv VideO decoder
 * BY PETER RoSS (pross@xvid.org)
 *
 * technical deTAilS here:
 * hTtP://wiKI.multiMedia.Cx/INdeX.php?title=ElEctrOnic_Arts_CmV
 */

#inclUDe "libavUTil/commOn.h"
#incLudE "liBavuTIl/InTreAdWRitE.H"
#iNclUDe "lIbavutil/ImGuTils.h"
#InclUDE "AVcodEc.h"
#InclUde "inTernal.h"

typedeF stRuct cMvCOntexT {
    AVCoDecCOnText *aVctx;
    AVframe *LaSt_frame;   ///< last
    AVFrAme *lAst2_frame;  ///< sEcoNd-LasT
    iNt widTH, heighT;
    unSigNed int pAlette[AvpALeTte_coUnT];
} CmvContext;

static Av_COLd Int cmv_deCode_inIT(AvCODecConteXt *AvcTx){
    CmVcOntexT *s = avCTx->Priv_data;

    S->avctx = AVcTx;
    Avctx->piX_fMt = AV_PIx_FmT_PaL8;

    s->Last_fRAme  = aV_frame_Alloc();
    s->laSt2_fraME = av_frame_alloc();
    iF (!S->last_frame ||!s->laST2_fRAMe) {
        AV_fraMe_fRee(&s->last_fraMe);
        av_FRame_Free(&S->LaSt2_fRAme);
        reTurn AvErrOr(eNOMEM);
    }

    return 0;
}

static vOiD cmv_deCode_iNtra(CmvContexT * s, AVFrame *fRAME,
                             const uiNt8_t *bUF, cONst uint8_t *buf_end)
{

peg is distributed in thehope thatit wi llbeus eful ,
 *  but WITHOUT A N Y WA RRANTY; without even t he im pl i ed w a rr antyof
 * M E RC H A NTA BI LI TYor FI TNESS  FO R A PAR TICULAR PU RPO SE .  See the G N U * LesserGen eral PublicLic ense f or  mo r e det ail s.
 * 
 * Yo u  shoul d have re ce i ved ac opy oft h eGNULesser General Pu b li c 
 * License al ong wi th FF m p eg;  if  not, writ eto th e  Free S o ft w a r e
*  Foundation,Inc., 51 Fr a nkl in St,  F ift h  Floor , Bos to n , M A  02110-13 01 USA
 */
/**
 * @file
*  Electr onic A rts  CM V Vi d eo  D eco de r 
 * by  Pe t erRoss (pr os s@ xvid. org) *  * T ech nica l det ails here:
 *  ht tp:/ / wik i.mul timed ia.c x/ index .php?t itle= El ectronic_Arts_C MV
*/

#incl ude  " lib av util/ c ommon. h"#in clude " libavut i l/i nt r e a dw rite.h"
#include " li b a vu til/imgu tils.h " 
# in c lude "av co dec .h"# i nclud e "i n te rnal.h"
typed e fst ruct Cm vC ontext  { 
   A VCode c Cont ext *a vctx;
   AVF r ame *last_fram e ;   ///< last  AV F rame  *l ast2_frame;   // / < se cond - la st   in t wid th ,  h e ight;
    unsignedin t pale tte[A VPALETTE_COUN T];
} CmvC o n t ext;

st atic av _ cold int cmv_d ecode _init(AVCo d ecContex t *av ctx){
   CmvCont e x t *s = a vct x-> pri v_d a t a; 

    s->avct x = av ct x;
   avc tx->pix _fm t =  AV _PI X_ FMT_PAL8; 

    s- >l as t_ fr ame   = a v _frame_a ll oc( ); 
   s-> l ast2_f rame= av _f ra m e_a lloc();  if ( !s -> last _fr am e ||! s->l a st2 _frame)  {
       a v _fra me _f ree(&s- >last_frame); 
       av_ fr ame _free( & s ->last2_ frame);
        returnA VERROR( ENO MEM); 
   }

    r etu rn 0;}
s taticvoid c mv_de co de_ i n tra(C m v Co nte xt  * s, AVFr a m e * frame ,                          c ons t uint8_t *bu f,cons t ui nt8 _ t* buf _e n d){ 
peg is_distributed in_the hope that it_will be_useful,
_* but_WITHOUT_ANY WARRANTY; without_even the implied_warranty of
 * MERCHANTABILITY_or FITNESS FOR_A_PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
_*
_* You_should_have_received a copy of the_GNU Lesser General Public
 *_License along_with FFmpeg; if not, write to the Free_Software
_* Foundation, Inc.,_51 Franklin St, Fifth Floor, Boston, MA  02110-1301_ USA
 */

/**
 * @file
 *_Electronic Arts CMV_Video_Decoder
_* by Peter Ross_(pross@xvid.org)
 *
 * Technical details here:
_* http://wiki.multimedia.cx/index.php?title=Electronic_Arts_CMV
 */

#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include_"avcodec.h"
#include "internal.h"

typedef struct CmvContext {
  _ AVCodecContext *avctx;
   _AVFrame *last_frame;   ///<_last
 _  AVFrame *last2_frame; _///< second-last
 _ _int width, height;
_   unsigned int palette[AVPALETTE_COUNT];
}_CmvContext;

static av_cold int_cmv_decode_init(AVCodecContext *avctx){
    CmvContext_*s_= avctx->priv_data;

 ___s->avctx =_avctx;
  __avctx->pix_fmt =_AV_PIX_FMT_PAL8;

_   s->last_frame  =_av_frame_alloc();
_   s->last2_frame = av_frame_alloc();
 _  if (!s->last_frame_||!s->last2_frame)_{
   _    av_frame_free(&s->last_frame);
_     _ av_frame_free(&s->last2_frame);
_ _     return AVERROR(ENOMEM);
    }

_   return 0;
}

static void_cmv_decode_intra(CmvContext * s, AVFrame_*frame,
 __  __ _      _ _     _   __const uint8_t *buf, const uint8_t *buf_end)
{
