ffmpeg / libavcodec

Everything else that doesn't fall into one of the other PB categories.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

ffmpeg / libavcodec

Post by Xombie »

Has anyone messed with getting libavcodec working with PB? Or hell, does anyone have a Windows compiled binary for libavcodec.dll (0.4.9-pre1) so I can try and get it working?

I'm curious to see how it stacks up performance-wise.
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

Hi Xombie,

I lately saw your request and I did compile for you and other intereseted developers an all-you-need package:
http://rapidshare.de/files/12421690/Libavcodec.rar.html

Files:
--------------------------

avcodec.def
avcodec.dll
avcodec.lib
avformat.def
avformat.dll
avformat.lib
avutil.dll
ffmpeg.exe
ffmpeg.txt <--------- just the cli reference of ffmpeg.exe
ffmpeg_static.exe
libavcodec.a
libavcodec.dll.a
libavformat.a
libavformat.dll.a
libavutil.a
output_example.c <--- VERY! VERY useful ;)
output_example.exe
Supported Formats.txt

dirs:
------------
include
lib



Also have a look in here:
http://www.inb.uni-luebeck.de/~boehme/u ... codec.html
http://www.inb.uni-luebeck.de/~boehme/l ... pdate.html
http://www.inb.uni-luebeck.de/~boehme/a ... sample.cpp

Im also VERY interested in getting Libavcodec working under PB or even as PB Userlib as this would make PB open for almost every common codec (audio and video) ..... see the "Supported Formats.txt" as the D and E initials in the listing do speak for themself. ;)

Libavcodec comes a plain C and a C based userlib which imho just contains simple wrappers to libavcodecs internal functions would really make sense as all routines in the LIBs do come as separate compiled objects and if you don't use av_register_all() in your apps. code but initializing a specific codec only then only the specified codec routines will be implementated in the final exe (imho) so the final PB resulted exe 'could' be kept small.



PS: Do download it till the end of this month as the file hoster "Rapidshare" does keep it available for you only for 30 days from now on.
ALSO: I did enable AC3 decoding via LibA52, so the whole package is GPL licensed, sorry but LibA52 is GPL'ed. If a true LGPL compile is wished, then it comes without AC3 decoding.
I'm curious to see how it stacks up performance-wise.
As PB itself will refer to the dll or the lib via a PB-Uerlibrary the perfomance of the main encoding/decoding will be as known as if Libavcodec would be used directly via the ffmpeg.exe binary, means: VERRRRRRRRY Fast. Its the fastest encoder engine I know, even a bit faster then CCE if you compare mpeg2 video encodings for instance.

If you do need further Libs, as maybe a linker could stuck in errors of i.e. unresolved external symbols, just do give me an advice and I'll provide you all you need like as LibFAAC.a, LibOgg.a or LibVorbis.a ... etc.

This Libavcodec PB approach also could be a blessing for Linux-PB users as it gots almost everything for decoding common image-, video- and audio formats.
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

And that was 2004...

Post by Philippe-felixer76 »

And that was 2004... how's the progress going on the PB AVCodec userlib?
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

If you can create me a infinite space-time continuum for having spare time, i could dig a bit but .. :lol:
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

Post by Philippe-felixer76 »

KarLKoX wrote:If you can create me a infinite space-time continuum for having spare time, i could dig a bit but .. :lol:
Now there are a few things i CAN do, creating a infinite space-time continuum would be one of them, if i hadn't dropped school, damn!

However, i can sing a song for you, with a terrible voice and timing. :P
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:lol:
Dare2 cut down to size
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Image Image
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

Another try in 2007?!

Post by Philippe-felixer76 »

KarLKoX wrote:Image Image
Did find this:

http://www.voxgratia.org/bin/libavcodec ... ws.bin.zip

I also looked into the header files, think i could convert
avcodec.h, but the common.h has got some ASM stuff
in there i think i can't convert.

And i have no experience in making userlibs for PB anyway.
With some experts help i would give it a go, who's up?

Gr,
Phil.
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

ALMOST WORKING - NEED SOME LITTLE HELP PLEASE..

Post by Philippe-felixer76 »

Hi there, i've been working on this libavcodec thing
for some time now, and i'm stuck i quess, it works
a bit now.

These are my DLL's:

http://arrozcru.no-ip.org/ffmpeg_builds/

These are my references:

http://www.inb.uni-luebeck.de/~boehme/l ... pdate.html
http://www.inb.uni-luebeck.de/~boehme/u ... codec.html
http://forums.shinywhitebox.com/viewtop ... 6c50641219

Some nice sample code:

http://www.inb.uni-luebeck.de/~boehme/a ... sample.cpp

I converted almost all needed header files from the C source,
i didn't put them in seperate files, just one source file.

I used the PB header conversion tool, i quess thats where part
of the problems start.

Here's my code so far, it does init and open the file ( a bit :)) :

Source and DLL's zipped:
http://members.chello.nl/j.vancalsteren ... dec-51.zip

Code: Select all

#LIBAVFORMAT_VERSION_INT = ((51<<16)+(12<<8)+1)
#LIBAVFORMAT_VERSION = "51.12.1"
#LIBAVFORMAT_BUILD = #LIBAVFORMAT_VERSION_INT
#LIBAVFORMAT_IDENT = "Lavf"
#MAX_REORDER_DELAY = 4
#AVFMTCTX_NOHEADER = $0001
#MAX_STREAMS = 20
#AVSEEK_FLAG_BACKWARD = 1
#AVSEEK_FLAG_BYTE = 2
#AVSEEK_FLAG_ANY = 4
#FFM_PACKET_SIZE = 4096
#AVPROBE_SCORE_MAX = 100
#AVPROBE_PADDING_SIZE = 32
#PKT_FLAG_KEY = $0001
#AVFMT_NOFILE = $0001
#AVFMT_NEEDNUMBER = $0002
#AVFMT_SHOW_IDS = $0008
#AVFMT_RAWPICTURE = $0020
#AVFMT_GLOBALHEADER = $0040
#AVFMT_NOTIMESTAMPS = $0080
#AVFMT_GENERIC_INDEX = $0100

Structure ByteIOContext 
    *buffer.c ;unsigned char *buffer;
    buffer_size.l ;int buffer_size;
    *buf_ptr.c ;
    *buf_end.c ;unsigned char *buf_ptr, *buf_end;
    *opaque.l ;void *opaque;
    *read_packet.l ;Int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
    *write_packet.l ;Int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
    offset.q
    whence.l;offset_t (*seek)(void *opaque, offset_t offset, int whence);
    pos.q ;.offset_t pos; /**< position in the file of the current buffer */
    must_flush.l; /**< true if the next seek should flush */
    eof_reached.l; /**< true if eof reached */
    write_flag.l;  /**< true if open for writing */
    is_streamed.l;
    max_packet_size.l;
    checksum.l;
    *checksum_ptr.c;
    *update_checksum.l ;unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
    error.l;         ///< contains the error code or 0 if no error happened
EndStructure

Structure AVRational
  num.l
  den.l
EndStructure

Structure AVPacket
  pts.q
  dts.q
 *data.b
  size.l
  stream_index.l
  flags.l
  duration.l
 *destruct.l
 *priv.l
  pos.q
EndStructure

Structure AVFrac ;attribute_deprecated
  val.q
  num.q
  den.q
EndStructure

Structure AVProbeData
 *filename.b
 *buf.b
  buf_size.l
EndStructure

Structure AVFormatParameters
  time_base.AVRational
  sample_rate.l;
  channels.l
  width.l
  height.l
  channel.l
 *device.b
 *standard.b
  ; PB header conversion did strange things below, just made longs out of them
  mpeg2ts_raw.l
  mpeg2ts_compute_pcr.l
  initial_pause.l
  prealloced_context.l
EndStructure

Structure AVOutputFormat
 *name.b
 *long_name.b
 *mime_type.b
 *extensions.b
  priv_data_size.l
 *write_header.l
 *write_packet.l
 *write_trailer.l
  flags.l
 *set_parameters.l
 *interleave_packet.l
 *next.AVOutputFormat
EndStructure

Structure AVInputFormat
 *name.b
 *long_name.b
  priv_data_size.l
 *read_probe.l
 *read_header.l
 *read_packet.l
 *read_close.l
 *read_seek.l
 *read_timestamp.l
  flags.l
 *extensions.b
  value.l
 *read_play.l
 *read_pause.l
 *next.AVInputFormat
EndStructure

Structure AVIndexEntry
  pos.q
  timestamp.q
  flags.l
  size.l
  min_distance.l
EndStructure

Structure AVFormatContext
 *av_class.AVClass
 *iformat.AVInputFormat
 *oformat.AVOutputFormat
 *priv_data.l
  pb.ByteIOContext
  nb_streams.l
 *streams.AVStream[#MAX_STREAMS]
  filename.b[1024]
  timestamp.q
  title.b[512]
  author.b[512]
  copyright.b[512]
  comment.b[512]
  album.b[512]
  year.l
  track.l
  genre.b[32]
  ctx_flags.l
 *packet_buffer.AVPacketList
  start_time.q
  duration.q
  file_size.q
  bit_rate.l
 *cur_st.AVStream
 *cur_ptr.b
  cur_len.l
  cur_pkt.AVPacket
  data_offset.q
  index_built.l
  mux_rate.l
  packet_size.l
  preload.l
  max_delay.l
  loop_output.l
  flags.l
  loop_input.l
  probesize.l
  max_analyze_duration.l
 *key.b
  keylen.l
EndStructure

Structure RcOverride
  start_frame.l;
  end_frame.l;
  qscale.l; // if this is 0 then quality_factor will be used instead
  quality_factor.f;
EndStructure;

Structure AVCodecContext 
    bit_rate.l;
    bit_rate_tolerance.l; 
    flags.l;
    sub_id.l;
    me_method.l;
    *extradata.l ;void *extradata;
    extradata_size.l;
    frame_rate.l;
    width.l
    height.l;
    gop_size.l;
    pixfmt.l ;pixfmt.PixelFormat ;enum PixelFormat pix_fmt;
    rate_emu.l;
    *draw_horiz_band.l
    ;void (*draw_horiz_band)(struct AVCodecContext *s,
    ;                        AVFrame *src, int offset[4],
    ;                        int y, int type, int height);
    sample_rate.l; ///< samples per sec 
    channels.l;
    sample_fmt.l;  ///< sample format, currenly unused 
    frame_size.l;     ///< in samples, initialized when calling 'init' 
    frame_number.l;   ///< audio or video frame number 
    real_pict_num.l;  ///< returns the real picture number of previous encoded frame 
    delay.l;
    qcompress.f ;float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
    qblur.f ;float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
    qmin.l;
    qmax.l;
    max_qdiff.l;
    max_b_frames.l;
    b_quant_factor.f;
    rc_strategy.l;
    b_frame_strategy.l;
    hurry_up.l;  
    *codec.AVCodec ;struct AVCodec *codec;
    *priv_data.l ;void *priv_data;
    rtp_mode.l;   /* 1 for activate RTP friendly-mode           */
    rtp_payload_size.l;   /* The size of the RTP payload: the coder will  */
    *rtp_callback.l
    ;void (*rtp_callback)(void *Data, int data_size,
    ;                     void *hdr, int hdr_size, void *priv_data);
    mv_bits.l;
    header_bits.l;
    i_tex_bits.l;
    p_tex_bits.l;
    i_count.l;
    p_count.l;
    skip_count.l;
    misc_bits.l;
    frame_bits.l;
    *opaque.l ;void *opaque;    
    codec_name.c[32];
    codec_type.l ;enum CodecType codec_type; /* see CODEC_TYPE_xxx */
    codec_id.l ;enum CodecID codec_id; /* see CODEC_ID_xxx */
    codec_tag.l ;unsigned codec_tag;
    workaround_bugs.l;
    luma_elim_threshold.l;
    chroma_elim_threshold.l;
    strict_std_compliance.l;
    b_quant_offset.f;
    error_resilience.l;
    *get_buffer.l ;(*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
    *release_buffer.l ;void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
    has_b_frames.l;
    block_align.l; ///< used by some WAV based audio codecs
    parse_only.l; /* - decoding only: if true, only parsing is done
    mpeg_quant.l;
    *stats_out.c;
    *stats_in.c;
    rc_qsquish.f;
    rc_qmod_amp.f;
    rc_qmod_freq.l;
    *rc_override.RcOverride;
    rc_override_count.l;
    *rc_eq.c;
    rc_max_rate.l;
    rc_min_rate.l;
    rc_buffer_size.l;
    rc_buffer_aggressivity.f;
    i_quant_factor.f;
    i_quant_offset.f;
    rc_initial_cplx.f;
    dct_algo.l;
    lumi_masking.f;
    temporal_cplx_masking.f;
    spatial_cplx_masking.f;
    p_masking.f;
    dark_masking.f;
    unused.l
    idct_algo.l;
    slice_count.l;
    *slice_offset.l;
    error_concealment.l;
    dsp_mask.l ;unsigned dsp_mask;
    bits_per_sample.l;
    prediction_method.l;
    aspect_ratio.f;
    *coded_frame.AVFrame ;AVFrame *coded_frame;
    Debug.l;
    error.q[4] ;uint64_t error[4];
    mb_qmin.l;
    mb_qmax.l;
    me_cmp.l;
    me_sub_cmp.l;
    mb_cmp.l;
    dia_size.l;
    last_predictor_count.l;
    pre_me.l;
    me_pre_cmp.l;
    pre_dia_size.l;
    me_subpel_quality.l;
    *get_format.l ;enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
    dtg_active_format.l;
    me_range.l;
    frame_rate_base.l;
    intra_quant_bias.l;
    inter_quant_bias.l;
    color_table_id.l;
    internal_buffer_count.l;
    *internal_buffer.l ;void *internal_buffer; 
    global_quality.l;  
    coder_type.l;
    context_model.l;
    slice_flags.l;
    xvmc_acceleration.l;
    mb_decision.l;
    *intra_matrix.w ;uint16_t *intra_matrix;
    *inter_matrix.w ;uint16_t *inter_matrix;
EndStructure  

Structure AVStream
  index.l
  id.l 
 *codec.AVCodecContext
  r_frame_rate.AVRational
 *priv_data.l
  codec_info_duration.q
  codec_info_nb_frames.l
  pts.AVFrac
  time_base.AVRational
  pts_wrap_bits.l
  stream_copy.l
  quality.f
  start_time.q
  duration.q
  language.b[4]
 *parser.AVCodecParserContext
  cur_dts.q
  last_IP_duration.l
  last_IP_pts.q
 *index_entries.AVIndexEntry
  nb_index_entries.l
  index_entries_allocated_size.l
  nb_frames.q
  pts_buffer.q[#MAX_REORDER_DELAY+1]
EndStructure

Structure AVPacketList
  pkt.AVPacket
 *next.AVPacketList
EndStructure

Structure AVFrame 
    FF_COMMON_FRAME.l
EndStructure

If OpenLibrary(0, "avformat-51.dll") And OpenLibrary(1, "avcodec-51.dll")
   
   ; ADJUST FILENAME TO YOUR LOCAL VIDEO FILE!!!!
   ; --------------------------------------------
   filename.s = "D:\persoonlijk\interesant\bruinsma\bb.laatste-klaas[1].asf"
   ;D:\persoonlijk\interesant\misc\blender_first_stage.avi"
   ;D:\persoonlijk\interesant\bruinsma\bb.laatste-klaas[1].asf"
   ;D:\persoonlijk\interesant\Icke\Icke-mq.mp3";const char *filename;
   
   *fmt.AVOutputFormat; *fmt;
   *oc.AVFormatContext; *oc;
   *ccx.AVCodecContext
   ;*codec.AVCodec  ; STILL TO DO, if we even reach this point ever .. :(
   
   *audio_st.AVStream
   *video_st.AVStream; AVStream *audio_st, *video_st;
   audio_pts.d
   video_pts.d; double audio_pts, video_pts;
   i.l; int i;
   *oc = AllocateMemory(SizeOf(AVFormatContext))
   *ccx= AllocateMemory(SizeOf(AVCodecContext))
   
   ; TEST, LIST ALL FUNCTIONS..
   ; --------------------------
   ;Result = ExamineLibraryFunctions(0)
   ;If Result
   ;   While NextLibraryFunction()
   ;      Debug LibraryFunctionName()  
   ;   Wend
   ;EndIf
   
   *F = GetFunction(0, "av_register_all")
   If *F
      Debug "av_register_all: "+Str(CallFunctionFast(*F))
   EndIf
   
   *F = GetFunction(0, "av_open_input_file") 
   If *F
      open = CallFunctionFast(*F, @*oc, filename.s, #Null, 0, #Null )
      Debug "av_open_input_file: "+Str(open)
   EndIf   

   *F = GetFunction(0, "av_find_stream_info") 
   If *F And open>-1
      streaminfo = CallFunctionFast(*F, *oc)
      Debug "av_find_stream_info: "+Str(streaminfo)
   EndIf   

   ;*F = GetFunction(0, "dump_format") 
   ;;VideoUtils.dump_format(pFormatContext, 0, this.SourceFilePath, 0); 
   ;;VideoUtils.AVFormatContext formatContext = (VideoUtils.AVFormatContext) 
   ;;Marshal.PtrToStructure(pFormatContext, typeof(VideoUtils.AVFormatContext));   
   ;If *F And open>-1 And streaminfo>0;
   ;   dumpformat = CallFunctionFast(*F, *oc, 0, GetPathPart(filename.s), 0) ;#False)
   ;   Debug "dump_format: "+Str(dumpformat)
   ;   ;formatcontext.AVFormatContext = *oc.AVFormatContext
   ;   ; PTR to Structure ????
   ;   Debug "Streams: "+Str(PeekL(*oc\nb_streams) & $FF )
   ;EndIf   
   
   ;Debug  PeekL(*oc\nb_streams)
   For i=0 To PeekL(*oc\nb_streams)
       If (*oc\streams[i]\codec\codec_type = 0) ;#CODEC_TYPE_VIDEO) 
          Debug "We have a video stream.."
       Else
          Debug "We have no video stream.."
       EndIf
   Next
   
   ; On to library 1, avcodec lib, we have no real *codec object here for now..
   ; we don't come to this point anyway... :(
   
   ;codec = avcodec_find_decoder(ccx->codec_id);   
   *F = GetFunction(1, "avcodec_find_decoder") 
   If *F And open>-1
      codec = CallFunctionFast(*F, *oc\streams[0]\codec\codec_id)
      Debug "avcodec_find_decoder: "+Str(codec)
   EndIf    
   
   ;err = avcodec_open(ccx, codec);
   *F = GetFunction(1, "avcodec_open") 
   If *F And open>-1
      open = CallFunctionFast(*F, @*oc\streams[0]\codec, @codec)
      Debug "avcodec_open: "+Str(open)
   EndIf      
   
   CloseLibrary(0)
   CloseLibrary(1)
EndIf
End
Hope someone can help a bit..
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

A little bit further ..

Post by Philippe-felixer76 »

Hi,

I converted more structures from the header files, now it
works better.

I can open a media file and get lot's of info, then i can
pre-buffer everything also.

The problem is, the width/height are totally wrong,
so i guess i didn't convert the header/structures right.

Code: Select all

#LIBAVFORMAT_VERSION_INT = ((51<<16)+(12<<8)+1)
#LIBAVFORMAT_VERSION = "51.12.1"
#LIBAVFORMAT_BUILD = #LIBAVFORMAT_VERSION_INT
#LIBAVFORMAT_IDENT = "Lavf"
#MAX_REORDER_DELAY = 4
#AVFMTCTX_NOHEADER = $0001
#MAX_STREAMS = 20
#AVSEEK_FLAG_BACKWARD = 1
#AVSEEK_FLAG_BYTE = 2
#AVSEEK_FLAG_ANY = 4
#FFM_PACKET_SIZE = 4096
#AVPROBE_SCORE_MAX = 100
#AVPROBE_PADDING_SIZE = 32
#PKT_FLAG_KEY = $0001
#AVFMT_NOFILE = $0001
#AVFMT_NEEDNUMBER = $0002
#AVFMT_SHOW_IDS = $0008
#AVFMT_RAWPICTURE = $0020
#AVFMT_GLOBALHEADER = $0040
#AVFMT_NOTIMESTAMPS = $0080
#AVFMT_GENERIC_INDEX = $0100
#CODEC_CAP_PARSE_ONLY = $0004
#CODEC_CAP_TRUNCATED  = $0008
#AV_PARSER_PTS_NB = 4
#PARSER_FLAG_COMPLETE_FRAMES = $0001
#AV_OPT_FLAG_ENCODING_PARAM = 1   
#AV_OPT_FLAG_DECODING_PARAM = 2   
#AV_OPT_FLAG_METADATA       = 4   
#AV_OPT_FLAG_AUDIO_PARAM    = 8
#AV_OPT_FLAG_VIDEO_PARAM    = 16
#AV_OPT_FLAG_SUBTITLE_PARAM = 32
#PIX_FMT_RGB24 = 2 ; from avutil.h

Structure ByteIOContext 
    *buffer.c ;unsigned char *buffer;
    buffer_size.l ;int buffer_size;
    *buf_ptr.c ;
    *buf_end.c ;unsigned char *buf_ptr, *buf_end;
    *opaque.l ;void *opaque;
    *read_packet.l ;Int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
    *write_packet.l ;Int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
    offset.q
    *seek.l ;whence.l;offset_t (*seek)(void *opaque, offset_t offset, int whence);
    pos.q ;.offset_t pos; /**< position in the file of the current buffer */
    must_flush.l; /**< true if the next seek should flush */
    eof_reached.l; /**< true if eof reached */
    write_flag.l;  /**< true if open for writing */
    is_streamed.l;
    max_packet_size.l;
    checksum.l;
    *checksum_ptr.c;
    *update_checksum.l ;unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
    error.l;         ///< contains the error code or 0 if no error happened
EndStructure

Structure AVRational
  num.l
  den.l
EndStructure

Structure AVPacket
  pts.q
  dts.q
 *data.b
  size.l
  stream_index.l
  flags.l
  duration.l
 *destruct.l
 *priv.l
  pos.q
EndStructure

Structure AVFrac ;attribute_deprecated
  val.q
  num.q
  den.q
EndStructure

Structure AVProbeData
 *filename.b
 *buf.b
  buf_size.l
EndStructure

Structure AVFormatParameters
  time_base.AVRational
  sample_rate.l;
  channels.l
  width.l
  height.l
  channel.l
 *device.b
 *standard.b
  ; PB header conversion did strange things below, just made longs out of them
  mpeg2ts_raw.l
  mpeg2ts_compute_pcr.l
  initial_pause.l
  prealloced_context.l
EndStructure

Structure AVOutputFormat
 *name.b
 *long_name.b
 *mime_type.b
 *extensions.b
  priv_data_size.l
 *write_header.l
 *write_packet.l
 *write_trailer.l
  flags.l
 *set_parameters.l
 *interleave_packet.l
 *next.AVOutputFormat
EndStructure

Structure AVInputFormat
 *name.b
 *long_name.b
  priv_data_size.l
 *read_probe.l
 *read_header.l
 *read_packet.l
 *read_close.l
 *read_seek.l
 *read_timestamp.l
  flags.l
 *extensions.b
  value.l
 *read_play.l
 *read_pause.l
 *next.AVInputFormat
EndStructure

Structure AVIndexEntry
  pos.q
  timestamp.q
  flags.l
  size.l
  min_distance.l
EndStructure

;typedef struct AVCLASS AVClass;
Structure AVClass 
    class_name.c ;const char* class_name;
    *item_name.c ;const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
		;			Or AVFormatContext, which begin With an AVClass.
		;			Needed because av_log is in libavcodec And has no visibility
		;			of AVIn/OutputFormat */
EndStructure

Structure AVFormatContext
 *av_class.AVClass
 *iformat.AVInputFormat
 *oformat.AVOutputFormat
 *priv_data.l
  pb.ByteIOContext
  nb_streams.l
 *streams.AVStream[#MAX_STREAMS]
  filename.b[1024]
  timestamp.q
  title.b[512]
  author.b[512]
  copyright.b[512]
  comment.b[512]
  album.b[512]
  year.l
  track.l
  genre.b[32]
  ctx_flags.l
 *packet_buffer.AVPacketList
  start_time.q
  duration.q
  file_size.q
  bit_rate.l
 *cur_st.AVStream
 *cur_ptr.b
  cur_len.l
  cur_pkt.AVPacket
  data_offset.q
  index_built.l
  mux_rate.l
  packet_size.l
  preload.l
  max_delay.l
  loop_output.l
  flags.l
  loop_input.l
  probesize.l
  max_analyze_duration.l
 *key.b
  keylen.l
EndStructure

Structure RcOverride
  start_frame.l;
  end_frame.l;
  qscale.l; // if this is 0 then quality_factor will be used instead
  quality_factor.f;
EndStructure;

Structure AVCodecContext 
    bit_rate.l;
    bit_rate_tolerance.l; 
    flags.l;
    sub_id.l;
    me_method.l;
    *extradata.l ;void *extradata;
    extradata_size.l;
    frame_rate.l;
    width.l
    height.l;
    gop_size.l;
    pixfmt.l ;pixfmt.PixelFormat ;enum PixelFormat pix_fmt;
    rate_emu.l;
    *draw_horiz_band.l
    ;void (*draw_horiz_band)(struct AVCodecContext *s,
    ;                        AVFrame *src, int offset[4],
    ;                        int y, int type, int height);
    sample_rate.l; ///< samples per sec 
    channels.l;
    sample_fmt.l;  ///< sample format, currenly unused 
    frame_size.l;     ///< in samples, initialized when calling 'init' 
    frame_number.l;   ///< audio or video frame number 
    real_pict_num.l;  ///< returns the real picture number of previous encoded frame 
    delay.l;
    qcompress.f ;float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
    qblur.f ;float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
    qmin.l;
    qmax.l;
    max_qdiff.l;
    max_b_frames.l;
    b_quant_factor.f;
    rc_strategy.l;
    b_frame_strategy.l;
    hurry_up.l;  
    *codec.AVCodec ;struct AVCodec *codec;
    *priv_data.l ;void *priv_data;
    rtp_mode.l;   /* 1 for activate RTP friendly-mode           */
    rtp_payload_size.l;   /* The size of the RTP payload: the coder will  */
    *rtp_callback.l
    ;void (*rtp_callback)(void *Data, int data_size,
    ;                     void *hdr, int hdr_size, void *priv_data);
    mv_bits.l;
    header_bits.l;
    i_tex_bits.l;
    p_tex_bits.l;
    i_count.l;
    p_count.l;
    skip_count.l;
    misc_bits.l;
    frame_bits.l;
    *opaque.l ;void *opaque;    
    codec_name.c[32];
    codec_type.l ;enum CodecType codec_type; /* see CODEC_TYPE_xxx */
    codec_id.l ;enum CodecID codec_id; /* see CODEC_ID_xxx */
    codec_tag.l ;unsigned codec_tag;
    workaround_bugs.l;
    luma_elim_threshold.l;
    chroma_elim_threshold.l;
    strict_std_compliance.l;
    b_quant_offset.f;
    error_resilience.l;
    *get_buffer.l ;(*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
    *release_buffer.l ;void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
    has_b_frames.l;
    block_align.l; ///< used by some WAV based audio codecs
    parse_only.l; /* - decoding only: if true, only parsing is done
    mpeg_quant.l;
    *stats_out.c;
    *stats_in.c;
    rc_qsquish.f;
    rc_qmod_amp.f;
    rc_qmod_freq.l;
    *rc_override.RcOverride;
    rc_override_count.l;
    *rc_eq.c;
    rc_max_rate.l;
    rc_min_rate.l;
    rc_buffer_size.l;
    rc_buffer_aggressivity.f;
    i_quant_factor.f;
    i_quant_offset.f;
    rc_initial_cplx.f;
    dct_algo.l;
    lumi_masking.f;
    temporal_cplx_masking.f;
    spatial_cplx_masking.f;
    p_masking.f;
    dark_masking.f;
    unused.l
    idct_algo.l;
    slice_count.l;
    *slice_offset.l;
    error_concealment.l;
    dsp_mask.l ;unsigned dsp_mask;
    bits_per_sample.l;
    prediction_method.l;
    aspect_ratio.f;
    *coded_frame.AVFrame ;AVFrame *coded_frame;
    Debug.l;
    error.q[4] ;uint64_t error[4];
    mb_qmin.l;
    mb_qmax.l;
    me_cmp.l;
    me_sub_cmp.l;
    mb_cmp.l;
    dia_size.l;
    last_predictor_count.l;
    pre_me.l;
    me_pre_cmp.l;
    pre_dia_size.l;
    me_subpel_quality.l;
    *get_format.l ;enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
    dtg_active_format.l;
    me_range.l;
    frame_rate_base.l;
    intra_quant_bias.l;
    inter_quant_bias.l;
    color_table_id.l;
    internal_buffer_count.l;
    *internal_buffer.l ;void *internal_buffer; 
    global_quality.l;  
    coder_type.l;
    context_model.l;
    slice_flags.l;
    xvmc_acceleration.l;
    mb_decision.l;
    *intra_matrix.w ;uint16_t *intra_matrix;
    *inter_matrix.w ;uint16_t *inter_matrix;
EndStructure  

Structure AVCodecParser
    codec_ids.l[5] ;int codec_ids[5]; /* several codec IDs are permitted */
    priv_data_size.l ;int priv_data_size;
    *parser_init.l ;AVCodecParserContext ;Int (*parser_init)(AVCodecParserContext *s);
    *parser_parse.l ;AVCodecParserContext ;Int (*parser_parse)(AVCodecParserContext *s,
    ;                    AVCodecContext *avctx,
    ;                    uint8_t **poutbuf, int *poutbuf_size,
    ;                    const uint8_t *buf, int buf_size);
    *parser_close.l ;AVCodecParserContext ;void (*parser_close)(AVCodecParserContext *s);
    *split.l ;AVCodecContect ;Int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
    *next.AVCodecParser ;struct AVCodecParser *Next;
EndStructure

Structure AVCodecParserContext
    *priv_data.l ;void *priv_data;
    *parser.AVCodecParser ;struct AVCodecParser *parser;   
    frame_offset.q ;int64_t frame_offset; /* offset of the current frame */
    cur_offset.q ;int64_t cur_offset; /* current offset
    ;                       (incremented by each av_parser_parse()) */
    last_frame_offset.q ;int64_t last_frame_offset; /* offset of the last frame */
    ;/* video info */
    pict_type.l ;int pict_type; /* XXX: put it back in AVCodecContext */
    repeat_pict.l ;int repeat_pict; /* XXX: put it back in AVCodecContext */
    pts.q ;int64_t pts;     /* pts of the current frame */
    dts.q ;int64_t dts;     /* dts of the current frame */
    ;/* private Data */
    last_pts.q ;int64_t last_pts;
    last_dts.q ;int64_t last_dts;
    fetch_timestamp.l ;int fetch_timestamp;
    cur_frame_start_index.l ;int cur_frame_start_index;
    cur_frame_offset.q[#AV_PARSER_PTS_NB] ;int64_t cur_frame_offset[#AV_PARSER_PTS_NB];
    cur_frame_pts.q[#AV_PARSER_PTS_NB] ;int64_t cur_frame_pts[#AV_PARSER_PTS_NB];
    cur_frame_dts.q[#AV_PARSER_PTS_NB] ;int64_t cur_frame_dts[#AV_PARSER_PTS_NB];
    flags.l ;int flags;
EndStructure

Structure AVStream
  index.l
  id.l 
 *codec.AVCodecContext
  r_frame_rate.AVRational
 *priv_data.l
  codec_info_duration.q
  codec_info_nb_frames.l
  pts.AVFrac
  time_base.AVRational
  pts_wrap_bits.l
  stream_copy.l
  quality.f
  start_time.q
  duration.q
  language.b[4]
 *parser.AVCodecParserContext
  cur_dts.q
  last_IP_duration.l
  last_IP_pts.q
 *index_entries.AVIndexEntry
  nb_index_entries.l
  index_entries_allocated_size.l
  nb_frames.q
  pts_buffer.q[#MAX_REORDER_DELAY+1]
EndStructure

Structure AVPacketList
  pkt.AVPacket
 *next.AVPacketList
EndStructure

Structure AVFrame 
    FF_COMMON_FRAME.l
EndStructure

Structure AVOption 
    *name.c   ;const char *name;
    *help.c   ;    const char *help;
    offset.l  ;int offset;             
    type.l ;AVOptionType ;enum AVOptionType type;
    default_val.d ;double default_val;
    min.d ;double min;
    max.d ;double max;
    flags.l ;  int flags;
    ; //FIXME think about enc-audio, ... style flags
    *unit.c ;const char *unit;
EndStructure

Structure AVCodec
    *name.c ;const char *name;
    type.l ;CodecType ;enum CodecType type;
    id.l; int id;
    priv_data_size.l ;int priv_data_size;
    *init.l ;AVCodecContext ;Int (*init)(AVCodecContext *);
    *encode.l ;AVCodecContext ;Int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *Data);
    *close.l ;AVCodecContext ;Int (*close)(AVCodecContext *);
    *decode.l ;AVCodecContext ;Int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
    ;*buf.b;              uint8_t *buf, int buf_size);  
    capabilities.l;
    *options.AVOption ;const AVOption *options;
    *next.AVCodec ;struct AVCodec *Next;
    *flush.l ;AVCodecContext ;void (*flush)(AVCodecContext *);
EndStructure


If OpenLibrary(0, "avformat-51.dll") And OpenLibrary(1, "avcodec-51.dll")
   
   ; ADJUST FILENAME TO YOUR LOCAL VIDEO FILE!!!!
   ; --------------------------------------------
   ;D:\persoonlijk\interesant\misc\blender_first_stage.avi
   ;D:\persoonlijk\interesant\bruinsma\bb.laatste-klaas[1].asf
   ;D:\video\BBC.Supernatural.Science.Electric.Hands.DivX521.MP3.www.mvgroup.org.avi
   ;D:\persoonlijk\interesant\Dekkers\bb.20061203.asf
   filename.s = "D:\persoonlijk\interesant\Dekkers\bb.20061203.asf"
   
   ; vars..
   *pFormatCtx.AVFormatContext
   *pCodecCtx.AVCodecContext   
   *pCodec.AVCodec
   *pFrame.AVFrame
   *pFrameRGB.AVFrame 
   numBytes.l
     
   ; Library 0 -> AVFORMAT.
   ; ----------------------
   ;Result = ExamineLibraryFunctions(0)
   ;If Result
   ;   While NextLibraryFunction()
   ;      Debug LibraryFunctionName()  
   ;   Wend
   ;EndIf
   
   *F = GetFunction(0, "av_register_all")
   If *F
      Debug "av_register_all: "+Str(CallFunctionFast(*F))
   EndIf
      
   *F = GetFunction(0, "av_open_input_file") 
   If *F
      open = CallFunctionFast(*F, @*pFormatCtx, filename.s, #Null, 0, #Null )
      Debug "av_open_input_file: "+Str(open)
   EndIf   
   
   *F = GetFunction(0, "av_find_stream_info") 
   If *F And open>-1
       streaminfo = CallFunctionFast(*F, *pFormatCtx)
      Debug "av_find_stream_info: "+Str(streaminfo)
   EndIf   

   *F = GetFunction(0, "dump_format")   
   If *F And open>-1 And streaminfo>0
      dumpformat = CallFunctionFast(*F, *pFormatCtx, 0, filename.s, 0) ;#False)
      Debug "dump_format: "+Str(dumpformat)
      ;; -------------------------------
      ;; LIST AVFormatContext structure: 
      ;; -------------------------------
      ;Debug "-> Sub-structure: *av_class.AVClass";
      ;Debug "   -> *av_class\class_name =  "+Str(*pFormatCtx\av_class\class_name)
      ;Debug "   -> *av_class\item_name =   "+Str(*pFormatCtx\av_class\item_name) 
      ;Debug "-> Sub-structure: *iformat.AVInputFormat"
      ;Debug "   -> *iformat\name =         "+PeekS(*pFormatCtx\iformat\name)
      ;Debug "   -> *iformat\long_name =    "+PeekS(*pFormatCtx\iformat\long_name)
      ;Debug "   -> *iformat\priv_data_size:"+Str(*pFormatCtx\iformat\priv_data_size)
      ;Debug "   -> *iformat\read_probe:    "+Str(*pFormatCtx\iformat\read_probe)
      ;Debug "   -> *iformat\read_header:   "+Str(*pFormatCtx\iformat\read_header)
      ;Debug "   -> *iformat\read_packet:   "+Str(*pFormatCtx\iformat\read_packet)
      ;Debug "   -> *iformat\read_close:    "+Str(*pFormatCtx\iformat\read_close)
      ;Debug "   -> *iformat\read_seek:     "+Str(*pFormatCtx\iformat\read_seek)
      ;Debug "   -> *iformat\read_timestamp:"+Str(*pFormatCtx\iformat\read_timestamp)
      ;Debug "   -> *iformat\flags:         "+Str(*pFormatCtx\iformat\flags)
      ;Debug "   -> *iformat\extensions:    "+Str(*pFormatCtx\iformat\extensions)
      ;Debug "   -> *iformat\value:         "+Str(*pFormatCtx\iformat\value)
      ;Debug "   -> *iformat\read_play:     "+Str(*pFormatCtx\iformat\read_play)
      ;Debug "   -> *iformat\read_pause:    "+Str(*pFormatCtx\iformat\read_pause)
      ;Debug "   -> *iformat\*next:         "+Str(*pFormatCtx\iformat\next)
      ;Debug "-> Sub-structure: *oformat.AVOutputFormat - NOT FILLED YET!"
      ;Debug "Priv_data: "+Str(*pFormatCtx\priv_data) ;.l
      ;; pb.ByteIOContext
      ; nb_streams.l
      ;*streams.AVStream[#MAX_STREAMS]
       Debug "------- INFO --------"
       a$=""
       For a = 0 To 1024-1
          a$ +  Chr(*pFormatCtx\filename[a])     
       Next
       Debug "Filename: "+a$  ; WHY WE MISS THE FIRST LETTER!!!!! Hmmmm .. 
       a$=""
       For a = 0 To 512-1
          a$ + Chr(*pFormatCtx\title[a])     
       Next
       Debug "Title:    "+a$
       a$=""
       For a = 0 To 512-1
          a$ + Chr(*pFormatCtx\author[a])
       Next
       Debug "Author:   "+a$
       a$=""
       For a = 0 To 512-1
          a$ + Chr(*pFormatCtx\copyright[a])     
       Next
       Debug "Copyright:"+a$
       a$=""
       For a = 0 To 512-1
          a$ + Chr(*pFormatCtx\comment[a])    
       Next
       Debug "Comment:  "+a$
       a$=""
       For a = 0 To 512-1
          a$ + Chr(*pFormatCtx\album[a])     
       Next
       Debug "Album:    "+a$
       Debug "Year:     "+Str(*pFormatCtx\year)
       Debug "Track:    "+Str(*pFormatCtx\track)
       a$=""
       For a = 0 To 32-1
          a$ + Chr(*pFormatCtx\genre[a])     
       Next
       Debug "Genre:    "+a$  
       Debug "---------------------"     
   EndIf   

   Debug "Streams: "+Str(PeekL(*pFormatCtx\nb_streams)) ;PeekL(*oc\nb_streams))   
   For i=0 To PeekL(*pFormatCtx\nb_streams) ;PeekL(*oc\nb_streams)
       If (*pFormatCtx\streams[i]\codec\codec_type=0) ;*oc\streams[i]\codec\codec_type = 0) ;#CODEC_TYPE_VIDEO) 
          Debug "We have a video stream.."
       Else
          Debug "We have no video stream.."
       EndIf
   Next
   
   ; Library 1 -> AVCODEC.
   ; ---------------------
   ;Result = ExamineLibraryFunctions(1)
   ;If Result
   ;   While NextLibraryFunction()
   ;      Debug LibraryFunctionName()  
   ;   Wend
   ;EndIf
    
   ;codec = avcodec_find_decoder(ccx->codec_id);   
   *F = GetFunction(1, "avcodec_find_decoder") 
   If *F And open>-1
      *pCodecCtx = @*pFormatCtx\streams[0]\codec
      *pCodec    = CallFunctionFast(*F, *pCodecCtx\codec_id)   
      ;*pCodec    = CallFunctionFast(*F, *pFormatCtx\streams[0]\codec\codec_id)
      Debug "avcodec_find_decoder: "+Str(*pCodec)
      If *pCodec=#Null
         Debug "No decoder codec!": End
      EndIf
   EndIf    

   ; If(pCodec->capabilities & CODEC_CAP_TRUNCATED) pCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
   If (*pCodec\capabilities & #CODEC_CAP_TRUNCATED)
       *pCodecCtx\flags = #CODEC_CAP_TRUNCATED
   EndIf  
   
   ;err = avcodec_open(ccx, codec);
   *F = GetFunction(1, "avcodec_open") 
   If *F And open>-1
      ;err = CallFunctionFast(*F, @*pCodecCtx, *pCodec) ; this one gives error!!
      err = CallFunctionFast(*F, *pFormatCtx\streams[0]\codec, *pCodec)
      Debug "avcodec_open: "+Str(err)
   EndIf      
  
   If open>-1 And err>-1 
      ;;If(pCodecCtx->frame_rate>1000 && pCodecCtx->frame_rate_base==1)
      ;;     pCodecCtx->frame_rate_base=1000;       
      ;Debug *pCodecCtx\frame_rate
      ;Debug *pFormatCtx\streams[0]\codec\frame_rate
      ;Debug *pCodecCtx\frame_rate_base ;frame_rate
      ;Debug *pFormatCtx\streams[0]\codec\frame_rate_base ;frame_rate    
      ;; Strange value's .. hmm ...
      
      ;pFrame=avcodec_alloc_frame();
      *F = GetFunction(1, "avcodec_alloc_frame") 
      If *F And open>-1
         *pFrame = CallFunctionFast(*F) ;, *pFormatCtx\streams[0]\codec, *pCodec)
         Debug "avcodec_alloc_frame: "+Str(*pFrame)
         If *pFrame
            ;// Allocate an AVFrame Structure
            ;pFrameRGB=avcodec_alloc_frame();  ;If(pFrameRGB==NULL) ;    Return -1;
            *F = GetFunction(1, "avcodec_alloc_frame")
            If *F And open>-1
               *pFrameRGB = CallFunctionFast(*F)
               Debug "avcodec_alloc_frame: "+Str(*pFrameRGB)
               ;// Determine required buffer size And allocate buffer
               ;numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
               ;    pCodecCtx->height);
               ;buffer=new uint8_t[numBytes];
                *F = GetFunction(1, "avpicture_get_size")
                If *F
                   ;numBytes = CallFunctionFast(*F, #PIX_FMT_RGB24, *pCodecCtx\width, *pCodecCtx\height)
                   ; *pFormatCtx\streams[0]\codec
                   numBytes = CallFunctionFast(*F, #PIX_FMT_RGB24, *pFormatCtx\streams[0]\codec\width,@*pFormatCtx\streams[0]\codec\height)
                   If numBytes
                      *buffer = AllocateMemory(numBytes)
                      ;Debug *pFormatCtx\streams[0]\codec\width ; 1000 ?????
                      ;Debug *pFormatCtx\streams[0]\codec\height; 1 ?????
                      ;// Assign appropriate parts of buffer To image planes in pFrameRGB
                      ;avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
                      ;    pCodecCtx->width, pCodecCtx->height);
                      *F = GetFunction(1, "avpicture_fill")
                      If *F
                         err = CallFunctionFast(*F, *pFrameRGB, *buffer, #PIX_FMT_RGB24, *pFormatCtx\streams[0]\codec\width, *pFormatCtx\streams[0]\codec\height)                                           
                         Debug "avpicture_fill: "+Str(err)
                         
                         
                         
                      EndIf 
                      FreeMemory(*buffer)
                   EndIf
                EndIf
            EndIf
         EndIf
      EndIf        
   EndIf
   
   CloseLibrary(0)
   CloseLibrary(1)
EndIf
End
Still help needed... :P
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

Thanks for getting into this :-)
I did some things in PB using Libavcodec some time ago ... last year.

Debug "Filename: "+a$ ; WHY WE MISS THE FIRST LETTER!!!!! Hmmmm .
This issue in combination with the wrong width/height outputs does clearly show that theres something wrong in your avformatcontext structure. Somewhere at the beginning you did define a structuremember wrong. I clearly do see that also in some of the other structures you do use pointers defined as for example "*myPointer.b" which makes no sense as pointers theirselfes in PB are always LONG in structures - so watch out.


Now something to your efforts. Please be aware that Libavcodec/ffmpeg is still in heavy development. If you follow the revision-chronology youll see that the avcodec.h and avformat.h and also other headers get updated almost every month .... so that would mean if you want to be compatible with recent compiles of the libs/dlls you would habe to update this PB header also.

My 2 cents with libavcodec are: Do program a simple wrapper fo the libavcodec functions. Cause if updates do occur you simply have to exchange the libavcodec headers&stuff but not your wrapper. :-)
Check out OOP support for PB here!
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

Libavcodec / libavformat DLL usage in PB

Post by Philippe-felixer76 »

inc. wrote:Thanks for getting into this :-)
I did some things in PB using Libavcodec some time ago ... last year.

Debug "Filename: "+a$ ; WHY WE MISS THE FIRST LETTER!!!!! Hmmmm .
This issue in combination with the wrong width/height outputs does clearly show that theres something wrong in your avformatcontext structure. Somewhere at the beginning you did define a structuremember wrong. I clearly do see that also in some of the other structures you do use pointers defined as for example "*myPointer.b" which makes no sense as pointers theirselfes in PB are always LONG in structures - so watch out.


Now something to your efforts. Please be aware that Libavcodec/ffmpeg is still in heavy development. If you follow the revision-chronology youll see that the avcodec.h and avformat.h and also other headers get updated almost every month .... so that would mean if you want to be compatible with recent compiles of the libs/dlls you would habe to update this PB header also.

My 2 cents with libavcodec are: Do program a simple wrapper fo the libavcodec functions. Cause if updates do occur you simply have to exchange the libavcodec headers&stuff but not your wrapper. :-)
Hi inc,

nice to see you reply. reading this post moved me to
get to this far.

I also figured it must be a header conversion problem
because of the same reasons. About the pointer, tnx,
i didn't know.. i'm used to C and pure but not to conversion :P

BTY i also susspect the 'enum' value in some C header structures
might be a byte instead of a long, wich i used now.. didn't test yet..

I know the lib is in heavy development, i'm a happy ffmpeg
and mplayer user for years.. :P

As i mentioned before the dll's and dev kit are from a web-site
and should be the same version..

I figure we all want a multi platform video alternative
next to directshow and/or the PB movie commands to
program with in PB.

I totally agree with your 2 cents but i don't need your cents
i need your help :)

Well, ill just try more and more .. who know's, we'll see..
Brosco
New User
New User
Posts: 2
Joined: Tue May 22, 2007 10:53 am
Location: Canberra

Re: A little bit further ..

Post by Brosco »

Philippe-felixer76 wrote:Hi,

I converted more structures from the header files, now it
works better.

I can open a media file and get lot's of info, then i can
pre-buffer everything also.

The problem is, the width/height are totally wrong,
so i guess i didn't convert the header/structures right.
Hi Philippe,

I'm a hobbiest Pascal programmer and I found this site/thread by Googling to look for help with my experimenting trying to use ffmpeg also.

I am about one tiny step ahead of you and so I believe I have found the problem you have with height and width. According to the Pascal headers I found:
TAVCodecContext = record {720}
(*** Info on struct for av_log
* - set by avcodec_alloc_context *)
av_class: PAVClass;
(*** the average bitrate.
* - encoding: set by user. unused for constant quantizer encoding
* - decoding: set by lavc. 0 or some bitrate if this info is available in the stream *)
bit_rate: integer;
(*** number of bits the bitstream is allowed to diverge from the reference.
* the reference can be CBR (for CBR pass1) or VBR (for pass2)
* - encoding: set by user. unused for constant quantizer encoding
* - decoding: unused *)
bit_rate_tolerance: integer;
(*** CODEC_FLAG_*.
* - encoding: set by user.
* - decoding: set by user. *)
flags: integer;
(*** some codecs needs additionnal format info. It is stored here
* - encoding: set by user.
* - decoding: set by lavc. (FIXME is this ok?) *)
sub_id: integer;

(**
* motion estimation algorithm used for video coding.
* 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
* 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
* - encoding: MUST be set by user.
* - decoding: unused *)
me_method: integer;

(**
* some codecs need / can use extra-data like huffman tables.
* mjpeg: huffman tables
* rv10: additional flags
* mpeg4: global headers (they can be in the bitstream or here)
* the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
* then extradata_size to avoid prolems if its read with the bitstream reader
* the bytewise contents of extradata must not depend on the architecture or cpu endianness
* - encoding: set/allocated/freed by lavc.
* - decoding: set/allocated/freed by user.
*)
extradata: pointer;
extradata_size: integer;

(**
* this is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. for fixed-fps content,
* timebase should be 1/framerate and timestamp increments should be
* identically 1.
* - encoding: MUST be set by user
* - decoding: set by lavc. *)
time_base: TAVRational;

(* video only *)
(*** picture width / height.
* - encoding: MUST be set by user.
* - decoding: set by lavc.
* Note, for compatibility its possible to set this instead of
* coded_width/height before decoding *)
width, height: integer;
(*** the number of pictures in a group of pitures, or 0 for intra_only.
* - encoding: set by user.
* - decoding: unused *)
gop_size: integer;
(*** pixel format, see PIX_FMT_xxx.
* - encoding: set by user.
* - decoding: set by lavc. *)
pix_fmt: TAVPixelFormat;
....................... etc ...............
The difference you have is that you missed the very first element:
av_class: PAVClass;
or in PB terms:
av_class: l {or however you code a pointer to another structure
So with that in the structure I have managed to successfully get the correct width and height.

From there I have made a couple more 'set up' calls which didn't crash, before I attempt to av_read_frame - which causes a crash I am trying to get past at the moment.

If you wish to continue to compare notes of our progress and help each other out - maybe we should do it privately and you could just report progress here?
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

Re: A little bit further ..

Post by Philippe-felixer76 »

Brosco wrote:
Philippe-felixer76 wrote:Hi,

I converted more structures from the header files, now it
works better.

I can open a media file and get lot's of info, then i can
pre-buffer everything also.

The problem is, the width/height are totally wrong,
so i guess i didn't convert the header/structures right.
Hi Philippe,

I'm a hobbiest Pascal programmer and I found this site/thread by Googling to look for help with my experimenting trying to use ffmpeg also.

I am about one tiny step ahead of you and so I believe I have found the problem you have with height and width. According to the Pascal headers I found:
TAVCodecContext = record {720}
(*** Info on struct for av_log
* - set by avcodec_alloc_context *)
av_class: PAVClass;
(*** the average bitrate.
* - encoding: set by user. unused for constant quantizer encoding
* - decoding: set by lavc. 0 or some bitrate if this info is available in the stream *)
bit_rate: integer;
(*** number of bits the bitstream is allowed to diverge from the reference.
* the reference can be CBR (for CBR pass1) or VBR (for pass2)
* - encoding: set by user. unused for constant quantizer encoding
* - decoding: unused *)
bit_rate_tolerance: integer;
(*** CODEC_FLAG_*.
* - encoding: set by user.
* - decoding: set by user. *)
flags: integer;
(*** some codecs needs additionnal format info. It is stored here
* - encoding: set by user.
* - decoding: set by lavc. (FIXME is this ok?) *)
sub_id: integer;

(**
* motion estimation algorithm used for video coding.
* 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
* 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
* - encoding: MUST be set by user.
* - decoding: unused *)
me_method: integer;

(**
* some codecs need / can use extra-data like huffman tables.
* mjpeg: huffman tables
* rv10: additional flags
* mpeg4: global headers (they can be in the bitstream or here)
* the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
* then extradata_size to avoid prolems if its read with the bitstream reader
* the bytewise contents of extradata must not depend on the architecture or cpu endianness
* - encoding: set/allocated/freed by lavc.
* - decoding: set/allocated/freed by user.
*)
extradata: pointer;
extradata_size: integer;

(**
* this is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. for fixed-fps content,
* timebase should be 1/framerate and timestamp increments should be
* identically 1.
* - encoding: MUST be set by user
* - decoding: set by lavc. *)
time_base: TAVRational;

(* video only *)
(*** picture width / height.
* - encoding: MUST be set by user.
* - decoding: set by lavc.
* Note, for compatibility its possible to set this instead of
* coded_width/height before decoding *)
width, height: integer;
(*** the number of pictures in a group of pitures, or 0 for intra_only.
* - encoding: set by user.
* - decoding: unused *)
gop_size: integer;
(*** pixel format, see PIX_FMT_xxx.
* - encoding: set by user.
* - decoding: set by lavc. *)
pix_fmt: TAVPixelFormat;
....................... etc ...............
The difference you have is that you missed the very first element:
av_class: PAVClass;
or in PB terms:
av_class: l {or however you code a pointer to another structure
So with that in the structure I have managed to successfully get the correct width and height.

From there I have made a couple more 'set up' calls which didn't crash, before I attempt to av_read_frame - which causes a crash I am trying to get past at the moment.

If you wish to continue to compare notes of our progress and help each other out - maybe we should do it privately and you could just report progress here?
Hi Brosco,

Hmmm dis might be a different header version problem i think ..

I think the best thing to do is to create my own dll's and convert
\the header files from that source.

Bye
Brosco
New User
New User
Posts: 2
Joined: Tue May 22, 2007 10:53 am
Location: Canberra

Post by Brosco »

If you do that - could you send me the DLLs you create and the C .h files so that I can convert them to pascal. That way we would both be working on the same version.

BTW you have a PM (this forum doesn't jump them out at you)

Brosco
Post Reply