} FILMPacket;
typedef struct FILMOutputContext {
- const AVClass *class;
int audio_index;
int video_index;
int64_t stab_pos;
info2 = pkt->duration;
/* The top bit being set indicates a key frame */
if (!pkt->keyframe)
- info1 |= (1 << 31);
+ info1 |= 1U << 31;
}
/* Write the 16-byte sample info packet to the STAB chunk in the header */
case AV_CODEC_ID_PCM_S8_PLANAR:
case AV_CODEC_ID_PCM_S16BE_PLANAR:
return 0;
- break;
case AV_CODEC_ID_ADPCM_ADX:
return 2;
- break;
default:
return -1;
}
av_log(format_context, AV_LOG_ERROR, "Sega FILM allows a maximum of one video stream.\n");
return AVERROR(EINVAL);
}
+ if (st->codecpar->codec_id != AV_CODEC_ID_CINEPAK &&
+ st->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ av_log(format_context, AV_LOG_ERROR,
+ "Incompatible video stream format.\n");
+ return AVERROR(EINVAL);
+ }
+ if (st->codecpar->format != AV_PIX_FMT_RGB24) {
+ av_log(format_context, AV_LOG_ERROR,
+ "Pixel format must be rgb24.\n");
+ return AVERROR(EINVAL);
+ }
film->video_index = i;
}
+ }
- if (film->video_index == -1) {
- av_log(format_context, AV_LOG_ERROR, "No video stream present.\n");
- return AVERROR(EINVAL);
- }
+ if (film->video_index == -1) {
+ av_log(format_context, AV_LOG_ERROR, "No video stream present.\n");
+ return AVERROR(EINVAL);
}
if (audio != NULL && get_audio_codec_id(audio->codecpar->codec_id) < 0) {
static int shift_data(AVFormatContext *format_context, int64_t shift_size)
{
int ret = 0;
- int64_t pos, pos_end = avio_tell(format_context->pb);
+ int64_t pos, pos_end;
uint8_t *buf, *read_buf[2];
int read_buf_id = 0;
int read_size[2];
}
}
- if (video->codecpar->format != AV_PIX_FMT_RGB24) {
- av_log(format_context, AV_LOG_ERROR, "Pixel format must be rgb24.\n");
- return AVERROR(EINVAL);
- }
-
/* First, write the FILM header; this is very simple */
ffio_wfourcc(pb, "FILM");
case AV_CODEC_ID_RAWVIDEO:
ffio_wfourcc(pb, "raw ");
break;
- default:
- av_log(format_context, AV_LOG_ERROR, "Incompatible video stream format.\n");
- return AVERROR(EINVAL);
}
avio_wb32(pb, video->codecpar->height);
avio_wb32(pb, film->packet_count);
- avio_flush(pb);
-
/* Finally, write out each packet's data to the header */
packet = film->start;
while (packet != NULL) {
return 0;
}
-static const AVClass film_muxer_class = {
- .class_name = "Sega FILM muxer",
- .item_name = av_default_item_name,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
AVOutputFormat ff_segafilm_muxer = {
.name = "film_cpk",
.long_name = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"),
.init = film_init,
.write_trailer = film_write_header,
.write_packet = film_write_packet,
- .priv_class = &film_muxer_class,
};