할일: ManagedDecoder.cpp에서, decodingRTSP에서 2종류의 avpacket을 한번만 선언해서 사용하기




pkt을 한번만 선언해서 av_free_packet(.)해도 계속 사용하는 사례

2015년에 작성된 H264 codec test 샘플코드임.


https://ffmpeg.org/doxygen/2.8/api-h264-test_8c_source.html#l00032


106  i = 0;
107  av_init_packet(&pkt);
108  do {
109  if (!end_of_stream)
110  if (av_read_frame(fmt_ctx, &pkt) < 0)
111  end_of_stream = 1;
112  if (end_of_stream) {
113  pkt.data = NULL;
114  pkt.size = 0;
115  }
116  if (pkt.stream_index == video_stream || end_of_stream) {
117  got_frame = 0;
118  if (pkt.pts == AV_NOPTS_VALUE)
119  pkt.pts = pkt.dts = i;
120  result = avcodec_decode_video2(ctx, fr, &got_frame, &pkt);
121  if (result < 0) {
122  av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n");
123  return result;
124  }
125  if (got_frame) {
126  number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
127  (const uint8_t* const *)fr->data, (const int*) fr->linesize,
128  ctx->pix_fmt, ctx->width, ctx->height, 1);
129  if (number_of_written_bytes < 0) {
130  av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
131  return number_of_written_bytes;
132  }
133  printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08lx\n", video_stream,
135  number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes));
136  }
137  av_free_packet(&pkt);
138  av_init_packet(&pkt);
139  }
140  i++;
141  } while (!end_of_stream || got_frame);







https://ffmpeg.org/doxygen/2.8/decoding__encoding_8c_source.html#l00347



Posted by 세모아
,