@@ -121,6 +121,8 @@ static int decode_frame(AVCodecContext *avctx,
121121{
122122 MSCCContext * s = avctx -> priv_data ;
123123 AVFrame * frame = data ;
124+ uint8_t * buf = avpkt -> data ;
125+ int buf_size = avpkt -> size ;
124126 GetByteContext gb ;
125127 PutByteContext pb ;
126128 int ret , j ;
@@ -130,15 +132,19 @@ static int decode_frame(AVCodecContext *avctx,
130132 if ((ret = ff_get_buffer (avctx , frame , 0 )) < 0 )
131133 return ret ;
132134
133- avpkt -> data [2 ] ^= avpkt -> data [0 ];
135+ if (avctx -> codec_id == AV_CODEC_ID_MSCC ) {
136+ avpkt -> data [2 ] ^= avpkt -> data [0 ];
137+ buf += 2 ;
138+ buf_size -= 2 ;
139+ }
134140
135141 ret = inflateReset (& s -> zstream );
136142 if (ret != Z_OK ) {
137143 av_log (avctx , AV_LOG_ERROR , "Inflate reset error: %d\n" , ret );
138144 return AVERROR_UNKNOWN ;
139145 }
140- s -> zstream .next_in = avpkt -> data + 2 ;
141- s -> zstream .avail_in = avpkt -> size - 2 ;
146+ s -> zstream .next_in = buf ;
147+ s -> zstream .avail_in = buf_size ;
142148 s -> zstream .next_out = s -> decomp_buf ;
143149 s -> zstream .avail_out = s -> decomp_size ;
144150 ret = inflate (& s -> zstream , Z_FINISH );
@@ -229,3 +235,15 @@ AVCodec ff_mscc_decoder = {
229235 .decode = decode_frame ,
230236 .capabilities = AV_CODEC_CAP_DR1 ,
231237};
238+
239+ AVCodec ff_srgc_decoder = {
240+ .name = "srgc" ,
241+ .long_name = NULL_IF_CONFIG_SMALL ("Screen Recorder Gold Codec" ),
242+ .type = AVMEDIA_TYPE_VIDEO ,
243+ .id = AV_CODEC_ID_SRGC ,
244+ .priv_data_size = sizeof (MSCCContext ),
245+ .init = decode_init ,
246+ .close = decode_close ,
247+ .decode = decode_frame ,
248+ .capabilities = AV_CODEC_CAP_DR1 ,
249+ };
0 commit comments