@@ -388,17 +388,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
fail)
pic->f.mb_type = pic->mb_type_base + 2 * s->mb_stride + 1;
pic->f.qscale_table = pic->qscale_table_base + 2 * s->mb_stride + 1;
- if (s->out_format == FMT_H264) {
- for (i = 0; i < 2; i++) {
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i],
- 2 * (b4_array_size + 4) * sizeof(int16_t),
- fail)
- pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i],
- 4 * mb_array_size * sizeof(uint8_t), fail)
- }
- pic->f.motion_subsample_log2 = 2;
- } else if (s->out_format == FMT_H263 || s->encoding ||
+ if (s->out_format == FMT_H263 || s->encoding ||
(s->avctx->debug & FF_DEBUG_MV) || s->avctx->debug_mv) {
for (i = 0; i < 2; i++) {
FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i],
@@ -936,7 +926,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
- else if (s->codec_id != AV_CODEC_ID_H264)
+ else
s->mb_height = (s->height + 15) / 16;
if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
@@ -1139,7 +1129,7 @@ int ff_MPV_common_frame_size_change(MpegEncContext *s)
// init
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
- else if (s->codec_id != AV_CODEC_ID_H264)
+ else
s->mb_height = (s->height + 15) / 16;
if ((s->width || s->height) &&
@@ -1419,27 +1409,25 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->mb_skipped = 0;
/* mark & release old frames */
- if (s->out_format != FMT_H264 || s->codec_id == AV_CODEC_ID_SVQ3) {
- if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
- s->last_picture_ptr != s->next_picture_ptr &&
- s->last_picture_ptr->f.data[0]) {
- if (s->last_picture_ptr->owner2 == s)
- free_frame_buffer(s, s->last_picture_ptr);
- }
-
- /* release forgotten pictures */
- /* if (mpeg124/h263) */
- if (!s->encoding) {
- for (i = 0; i < s->picture_count; i++) {
- if (s->picture[i].owner2 == s && s->picture[i].f.data[0] &&
- &s->picture[i] != s->last_picture_ptr &&
- &s->picture[i] != s->next_picture_ptr &&
- s->picture[i].f.reference && !s->picture[i].needs_realloc) {
- if (!(avctx->active_thread_type & FF_THREAD_FRAME))
- av_log(avctx, AV_LOG_ERROR,
- "releasing zombie picture\n");
- free_frame_buffer(s, &s->picture[i]);
- }
+ if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
+ s->last_picture_ptr != s->next_picture_ptr &&
+ s->last_picture_ptr->f.data[0]) {
+ if (s->last_picture_ptr->owner2 == s)
+ free_frame_buffer(s, s->last_picture_ptr);
+ }
+
+ /* release forgotten pictures */
+ /* if (mpeg124/h263) */
+ if (!s->encoding) {
+ for (i = 0; i < s->picture_count; i++) {
+ if (s->picture[i].owner2 == s && s->picture[i].f.data[0] &&
+ &s->picture[i] != s->last_picture_ptr &&
+ &s->picture[i] != s->next_picture_ptr &&
+ s->picture[i].f.reference && !s->picture[i].needs_realloc) {
+ if (!(avctx->active_thread_type & FF_THREAD_FRAME))
+ av_log(avctx, AV_LOG_ERROR,
+ "releasing zombie picture\n");
+ free_frame_buffer(s, &s->picture[i]);
}
}
}
@@ -1463,9 +1451,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
pic->f.reference = 0;
if (!s->droppable) {
- if (s->codec_id == AV_CODEC_ID_H264)
- pic->f.reference = s->picture_structure;
- else if (s->pict_type != AV_PICTURE_TYPE_B)
+ if (s->pict_type != AV_PICTURE_TYPE_B)
pic->f.reference = 3;
}
@@ -1507,64 +1493,62 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL,
s->pict_type, s->droppable);
- if (s->codec_id != AV_CODEC_ID_H264) {
- if ((s->last_picture_ptr == NULL ||
- s->last_picture_ptr->f.data[0] == NULL) &&
- (s->pict_type != AV_PICTURE_TYPE_I ||
- s->picture_structure != PICT_FRAME)) {
- int h_chroma_shift, v_chroma_shift;
- av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
- &h_chroma_shift, &v_chroma_shift);
- if (s->pict_type != AV_PICTURE_TYPE_I)
- av_log(avctx, AV_LOG_ERROR,
- "warning: first frame is no keyframe\n");
- else if (s->picture_structure != PICT_FRAME)
- av_log(avctx, AV_LOG_INFO,
- "allocate dummy last picture for field based first keyframe\n");
-
- /* Allocate a dummy frame */
- i = ff_find_unused_picture(s, 0);
- if (i < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- s->last_picture_ptr = &s->picture[i];
- if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
- s->last_picture_ptr = NULL;
- return -1;
- }
+ if ((s->last_picture_ptr == NULL ||
+ s->last_picture_ptr->f.data[0] == NULL) &&
+ (s->pict_type != AV_PICTURE_TYPE_I ||
+ s->picture_structure != PICT_FRAME)) {
+ int h_chroma_shift, v_chroma_shift;
+ av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
+ &h_chroma_shift, &v_chroma_shift);
+ if (s->pict_type != AV_PICTURE_TYPE_I)
+ av_log(avctx, AV_LOG_ERROR,
+ "warning: first frame is no keyframe\n");
+ else if (s->picture_structure != PICT_FRAME)
+ av_log(avctx, AV_LOG_INFO,
+ "allocate dummy last picture for field based first keyframe\n");
+
+ /* Allocate a dummy frame */
+ i = ff_find_unused_picture(s, 0);
+ if (i < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
+ return i;
+ }
+ s->last_picture_ptr = &s->picture[i];
+ if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
+ s->last_picture_ptr = NULL;
+ return -1;
+ }
- memset(s->last_picture_ptr->f.data[0], 0,
- avctx->height * s->last_picture_ptr->f.linesize[0]);
- memset(s->last_picture_ptr->f.data[1], 0x80,
- (avctx->height >> v_chroma_shift) *
- s->last_picture_ptr->f.linesize[1]);
- memset(s->last_picture_ptr->f.data[2], 0x80,
- (avctx->height >> v_chroma_shift) *
- s->last_picture_ptr->f.linesize[2]);
-
- ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 0);
- ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
- s->last_picture_ptr->f.reference = 3;
- }
- if ((s->next_picture_ptr == NULL ||
- s->next_picture_ptr->f.data[0] == NULL) &&
- s->pict_type == AV_PICTURE_TYPE_B) {
- /* Allocate a dummy frame */
- i = ff_find_unused_picture(s, 0);
- if (i < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- s->next_picture_ptr = &s->picture[i];
- if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
- s->next_picture_ptr = NULL;
- return -1;
- }
- ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 0);
- ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 1);
- s->next_picture_ptr->f.reference = 3;
+ memset(s->last_picture_ptr->f.data[0], 0,
+ avctx->height * s->last_picture_ptr->f.linesize[0]);
+ memset(s->last_picture_ptr->f.data[1], 0x80,
+ (avctx->height >> v_chroma_shift) *
+ s->last_picture_ptr->f.linesize[1]);
+ memset(s->last_picture_ptr->f.data[2], 0x80,
+ (avctx->height >> v_chroma_shift) *
+ s->last_picture_ptr->f.linesize[2]);
+
+ ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
+ s->last_picture_ptr->f.reference = 3;
+ }
+ if ((s->next_picture_ptr == NULL ||
+ s->next_picture_ptr->f.data[0] == NULL) &&
+ s->pict_type == AV_PICTURE_TYPE_B) {
+ /* Allocate a dummy frame */
+ i = ff_find_unused_picture(s, 0);
+ if (i < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
+ return i;
}
+ s->next_picture_ptr = &s->picture[i];
+ if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
+ s->next_picture_ptr = NULL;
+ return -1;
+ }
+ ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 1);
+ s->next_picture_ptr->f.reference = 3;
}
if (s->last_picture_ptr)
@@ -1582,7 +1566,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
s->last_picture_ptr->f.data[0]));
- if (s->picture_structure!= PICT_FRAME && s->out_format != FMT_H264) {
+ if (s->picture_structure != PICT_FRAME) {
int i;
for (i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
@@ -1690,7 +1674,7 @@ void ff_MPV_frame_end(MpegEncContext *s)
#endif
s->avctx->coded_frame = &s->current_picture_ptr->f;
- if (s->codec_id != AV_CODEC_ID_H264 && s->current_picture.f.reference) {
+ if (s->current_picture.f.reference) {
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
}
}
@@ -1890,8 +1874,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
const int width = s->avctx->width;
const int height = s->avctx->height;
const int mv_sample_log2 = 4 - pict->motion_subsample_log2;
- const int mv_stride = (s->mb_width << mv_sample_log2) +
- (s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
+ const int mv_stride = (s->mb_width << mv_sample_log2) + 1;
s->low_delay = 0; // needed to see the vectors without trashing the buffers
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
@@ -2078,11 +2061,6 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
pict->linesize[0]) ^= 0x8080808080808080ULL;
}
}
-
- if (IS_INTERLACED(mb_type) &&
- s->codec_id == AV_CODEC_ID_H264) {
- // hmm
- }
}
s->mbskip_table[mb_index] = 0;
}
@@ -2499,7 +2477,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
if (cur->f.pict_type == AV_PICTURE_TYPE_B &&
picture_structure == PICT_FRAME &&
- avctx->codec_id != AV_CODEC_ID_H264 &&
avctx->codec_id != AV_CODEC_ID_SVQ3) {
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
offset[i] = 0;
@@ -48,7 +48,6 @@ enum OutputFormat {
FMT_H261,
FMT_H263,
FMT_MJPEG,
- FMT_H264,
};
#define MPEG_BUF_SIZE (16 * 1024)
@@ -3310,8 +3310,6 @@ static int encode_picture(MpegEncContext *s, int picture_number)
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
ff_mpeg1_encode_picture_header(s, picture_number);
break;
- case FMT_H264:
- break;
default:
assert(0);
}